Skip to content

Pass Deep Agents tool_choice through the provider's bind_tools - #249

Merged
brianstrauch merged 4 commits into
temporalio:mainfrom
sohom-cs:deepagents-tool-choice
Oct 29, 2026
Merged

brianstrauch merged 4 commits into
temporalio:mainfrom
sohom-cs:deepagents-tool-choice

Conversation

@sohom-cs

@sohom-cs sohom-cs commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

DeepAgentActivities._build_bound_model now passes tool_choice and parallel_tool_calls to the provider's bind_tools instead of .bind(). Other bind options still go through .bind(), as before.

Why?

Providers convert these two options only inside bind_tools. Without that, create_agent's tool_choice="any" (used for structured output) reaches Anthropic as "any" instead of {"type": "any"}, and OpenAI-compatible servers as "any" instead of "required". vLLM answers with a 400. Details and an offline repro are in #248.

The activity input does not change, so no patched gate is needed and existing histories replay as before. The test from temporalio/sdk-python#1901 (test_model_binding_preserves_kwargs_with_tools) still passes: its fake bind_tools keeps raw kwargs, so it sees the same result on either path.

Checklist

  1. Closes [Bug] Deep Agents sends tool_choice "any" without the provider's conversion; vLLM rejects it #248

  2. How was this tested:

    • New test_tool_options_go_to_bind_tools wraps the test's _ToolBindingModel in Mock(wraps=...) and checks that bind_tools receives tool_choice and parallel_tool_calls, separately and together, while other options still go through .bind(). On main all three cases fail; with the change they pass.
    • test_tool_options_use_provider_format builds the real Anthropic request payload offline: 'any' becomes {'type': 'any'}, and parallel_tool_calls=False becomes disable_parallel_tool_use. On main both cases fail.
    • make lint passes. Plugin suite: 98 passed, none skipped (main: 93 passed).
  3. Any docs updates needed? No.

I used an AI assistant while tracing this and writing the tests; I reviewed every line and ran the tests myself.

The model activity bound tool schemas with bind_tools() and then applied
tool_choice and parallel_tool_calls with .bind(). Providers convert these
options only inside bind_tools(), so the raw values reached the API:
create_agent's tool_choice="any" went to Anthropic as "any" instead of
{"type": "any"}, and to OpenAI-compatible servers as "any" instead of
"required", which vLLM rejects with a 400.

Pass both options to bind_tools() on the worker. The activity input is
unchanged, so existing histories are not affected.

Fixes temporalio#248

Signed-off-by: sohomchakraborty <16609933+sohom-cs@users.noreply.github.com>
@sohom-cs
sohom-cs requested a review from a team as a code owner October 28, 2026 01:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T01:06:44.404024Z
We couldn’t complete this review. Comment @codex review to try again.
1dab3c4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@CLAassistant

CLAassistant commented Oct 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@brianstrauch brianstrauch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please make the new regression coverage run with the plugin's committed CI dependencies before merging. A provider-independent forwarding test should let us address the skipped case without adding a development dependency; see the inline suggestion.

Comment thread python/deepagents/tests/test_model_activity.py Outdated
@sohom-cs
sohom-cs requested a review from brianstrauch October 28, 2026 23:47

@brianstrauch brianstrauch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@sohom-cs

Copy link
Copy Markdown
Contributor Author

@brianstrauch Thanks for the review! Could you merge this when you get a chance?

@brianstrauch
brianstrauch enabled auto-merge (squash) October 29, 2026 17:49
@brianstrauch
brianstrauch merged commit 9639bcc into temporalio:main Oct 29, 2026
15 checks passed
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] Deep Agents sends tool_choice "any" without the provider's conversion; vLLM rejects it

3 participants