Skip to content

Stop forwarding agent_tools to the provider in sync invoke - #89

Merged
mattprintz merged 1 commit into
mainfrom
fix-sync-invoke-agent-tools
Jul 29, 2026
Merged

Stop forwarding agent_tools to the provider in sync invoke#89
mattprintz merged 1 commit into
mainfrom
fix-sync-invoke-agent-tools

Conversation

@brandomr

Copy link
Copy Markdown
Collaborator

BaseArchytasModel.invoke passed agent_tools through to the underlying LangChain model. LangChain forwards kwargs it does not recognize into the provider request, so it reaches the OpenAI client and raises before any request is made:

TypeError: Completions.create() got an unexpected keyword argument 'agent_tools'

It was forwarded unconditionally, including the default None, so any sync invoke against an OpenAI-compatible provider failed regardless of whether tools were passed. ainvoke already consumed the argument via set_tools; invoke now does the same.

Found via beaker-notebook's streamline exporter, which is the sync caller behind its AI notebook export. That export fails on 2.0.6 with the traceback above and works with this change.

Tests: three cases in tests/test_sync_invoke_agent_tools.py using a chat model stub that rejects unknown kwargs the way the OpenAI client does. All three fail on main with the TypeError above. The 15 test_mcp_tools.py failures in my environment are a local mcp version mismatch and reproduce on unmodified main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01555XSwMPRxBZFAEsvubUMz

BaseArchytasModel.invoke passed agent_tools through to the underlying
LangChain model, which forwards unrecognized kwargs into the provider
request. The OpenAI client rejects it:

  TypeError: Completions.create() got an unexpected keyword argument 'agent_tools'

It was forwarded unconditionally, including the default None, so any sync
invoke against an OpenAI-compatible provider failed before a request was
made. ainvoke already consumed the argument via set_tools; invoke now does
the same.

@mattprintz mattprintz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@mattprintz
mattprintz merged commit 86f9572 into main Jul 29, 2026
1 check passed
@mattprintz
mattprintz deleted the fix-sync-invoke-agent-tools branch July 29, 2026 15:19
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.

2 participants