Skip to content

fix(auxiliary): validate response shape in call_llm/async_call_llm#7631

Closed
kshitijk4poor wants to merge 1 commit intoNousResearch:mainfrom
kshitijk4poor:fix/async-response-validation
Closed

fix(auxiliary): validate response shape in call_llm/async_call_llm#7631
kshitijk4poor wants to merge 1 commit intoNousResearch:mainfrom
kshitijk4poor:fix/async-response-validation

Conversation

@kshitijk4poor
Copy link
Copy Markdown
Collaborator

Problem

async_call_llm() can return non-OpenAI objects (bare strings, dicts, etc.) from custom providers or adapter shims. These propagate to downstream consumers like session_search_tool.py which crashes with a misleading AttributeError: 'str' object has no attribute 'choices'.

Changes

  • Add _validate_llm_response() that checks the response has the expected .choices[0].message shape
  • Wrap all return paths in call_llm(), async_call_llm(), and payment fallback paths
  • Fails fast with a clear RuntimeError identifying the task, response type, and a preview of the malformed payload

Closes #7264
Part of #7605

…ousResearch#7264)

async_call_llm (and call_llm) can return non-OpenAI objects from
custom providers or adapter shims, crashing downstream consumers
with misleading AttributeError ('str' has no attribute 'choices').

Add _validate_llm_response() that checks the response has the
expected .choices[0].message shape before returning. Wraps all
return paths in call_llm, async_call_llm, and fallback paths.
Fails fast with a clear RuntimeError identifying the task, response
type, and a preview of the malformed payload.

Closes NousResearch#7264
@teknium1
Copy link
Copy Markdown
Contributor

Merged via #7647. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks @kshitijk4poor!

@teknium1 teknium1 closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: auxiliary async model path can return invalid payloads and crash session_search with misleading AttributeError

2 participants