Conversation
generation_kwargs.tools was forwarded to OpenAI chat generators and overwrote Agent.tools. Treat those specs as client-side: offer them to the LLM with Agent tools, invoke only Agent tools, and stop with exit_reason=client_tools so the caller can run the rest.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Share client-tool planning and post-invoke logic between sync and async agent steps, and move OpenAI tool-definition merging into generators/utils to avoid a new chat submodule for schema import. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Sep 21, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent.run(..., generation_kwargs={"tools": [...]})currently forwards those OpenAI specs into the chat generator. OpenAI chat generators last-write-wins-mergegeneration_kwargsover thetoolsargument, so Agent tools disappear from the model.generation_kwargs["tools"]as client-side specs: they are offered to the LLM alongsideagent.tools, popped out ofgeneration_kwargsso they cannot overwrite, and never invoked by the Agent.exit_reason="client_tools"and leaves the tool-call message for the caller. If the model also calls an Agent tool, the Agent invokes the owned calls, then stops the same way so the next LLM turn is not missing tool results.Draft on purpose: this is a proposed Haystack change so mixed Agent + client tool catalogs work (OpenAI-compatible
/chat/completionswith a server-side Agent). Happy to reshape the API (exit_reason, whethertoolsbelongs ingeneration_kwargsat all) before this is considered for merge.Related Issues
Proposed Changes
toolsfrom run-timegeneration_kwargsand turn function specs into spec-only HaystackToolstubs.current_tools + client_side_toolsinto the chat generator.generation_kwargs["tools"]are skipped. Truly unknown names still go through the existing ToolNotFound path.How did you test it?
Unit tests in
test/components/agents/test_agent.py:generation_kwargsexit_reason=client_tools)Notes for the reviewer
The generator-level last-write-wins merge in
OpenAIChatGenerator._prepare_api_call({**openai_tools, **generation_kwargs}) is the other half of this bug. This PR fixes the Agent path by not puttingtoolsintogeneration_kwargs. A generator merge would still help callers that useOpenAIChatGenerator.run(tools=..., generation_kwargs={"tools": ...})directly, including leftover built-in OpenAI tools that cannot be expressed as HaystackToolobjects.Checklist
Made with Cursor