Skip to content

fix: resolve callable API keys in auxiliary custom endpoint (#79121) - #79150

Open
RelaxJonh wants to merge 1 commit into
NousResearch:mainfrom
RelaxJonh:fix/vision-analyze-callable-api-key
Open

RelaxJonh wants to merge 1 commit into
NousResearch:mainfrom
RelaxJonh:fix/vision-analyze-callable-api-key

Conversation

@RelaxJonh

Copy link
Copy Markdown

Summary

vision_analyze crashes with AttributeError: 'function' object has no attribute 'strip' when the main runtime uses a callable api_key (short-lived credential supplier) with a custom OpenAI-compatible endpoint.

Root Cause

The auxiliary client's custom-endpoint branch in resolve_provider_client() calls .strip() directly on explicit_api_key without resolving callables first. The runtime path (line 3069) already preserves callables with api_key if callable(api_key), but the auxiliary resolution path crashes when it encounters a callable.

Two code paths affected:

  1. explicit_base_url path (line 5953): (explicit_api_key or "").strip() — callable is truthy, so callable or "" returns the callable, then .strip() raises AttributeError
  2. main_runtime fallback path (line 5977): str(main_runtime.get("api_key") or "").strip() — str(callable) returns "<function ...>", which is a string but wrong as an API key

Fix

Resolve callable API keys before string operations in both paths:

  • Call the callable and normalize the result to a stripped string
  • Consistent with the runtime path's existing callable handling pattern

Test Plan

  • Syntax check passes
  • Callable explicit_api_key with custom endpoint resolves correctly
  • String explicit_api_key continues to work unchanged
  • main_runtime with callable api_key resolves correctly

Fixes #79121

…endpoint

vision_analyze crashes with AttributeError when the main runtime uses a
callable api_key (e.g. short-lived credential supplier) with a custom
OpenAI-compatible endpoint. The auxiliary client's custom-endpoint branch
calls .strip() directly on explicit_api_key without resolving callables
first, while the runtime path already preserves callables.

Fix both the explicit_base_url path (line 5953) and the main_runtime
fallback path (line 5977) by resolving callable API keys before string
operations.

Fixes NousResearch#79121
@samrusani

Copy link
Copy Markdown

I validated this exact head (6843d07fec) with focused callable-key coverage and prepared a test-only commit on top of it: ff85c31b36a891303c675447d5f34ae35eb38fd7. It covers the async vision path with a callable explicit key and the adjacent callable main_runtime path, asserting one evaluation, stripped token forwarding, and no callable object or function representation reaching client construction. Exact-head result: 17 passed; Ruff and git diff --check also pass. Feel free to cherry-pick ff85c31b36.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/vision Vision analysis and image generation provider/openai OpenAI / Codex Responses API labels Aug 5, 2026
@baglett

baglett commented Sep 27, 2026

Copy link
Copy Markdown

Withdrawing this PR — closing as part of a cleanup pass on our submitted contributions.

@baglett

baglett commented Sep 27, 2026

Copy link
Copy Markdown

Withdrawing this PR as part of a contribution cleanup pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: vision_analyze crashes with callable API key on custom OpenAI-compatible endpoints

5 participants