Skip to content

fix(roadmap): send tool choice auto to Claude and count answers - #4216

Merged
dan-petty merged 4 commits into
mainfrom
fix/4205-claude-forced-tool-choice-fallback
Nov 9, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/4205-claude-forced-tool-choice-fallback

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A Claude group answered 400 to tool_choice required, which an agent with a tool output sends. The gateway fallback hid the 400, so a slot that read claude-sonnet-5-5 was answered by deepseek-v4.1-flash-1017. A Claude group on a gateway now takes the model profile supports_forced_tool_choice=False, so the agent sends auto with the same tools. Other models keep the default. A run now records the model that answered (response.model) in the spend ledger and counts it in devops_cli_ai_model_answers_total, with the labels asked, answered and fallback. The series count is at most 18. The gateway fallback is not changed: a person decides.

Closes #4205

Change: openspec/changes/archive/2026-11-09-4205-claude-group-sends-tool-choice-auto/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 9, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record of #4205.

fail-to-pass against origin/main (devops ci fail-to-pass --base origin/main): 9 tests failed on base, 0 errored; they pass on the branch. Failed on base, for example: test_a_claude_group_is_sent_tool_choice_auto_for_a_tool_output[claude-haiku-5-5] ('required' instead of 'auto') and test_a_claude_group_profile_allows_no_forced_tool_choice. Tests for a non-Claude model (devops-chat, deepseek-v4.1-flash-1017) pass on base and branch: the default stays. Tests: tests/ai/test_pydantic_ai_profiles_and_providers.py, tests/ai/client/test_roadmap_agent_run.py.

Full devops ci on the final code tree (36c4f9e): all rows pass. The pytest row took 10 min 40 s, over the 5 min limit; this is the known issue #3593, not caused by this change.

Exact field: the issue names openai_supports_tool_choice_required. In pydantic-ai 2.59.0 it is deprecated and raises a deprecation warning. The change uses the profile key supports_forced_tool_choice=False.

Series count of devops_cli_ai_model_answers_total (labels asked, answered, fallback): at most 18 = 11 chat groups that answer as themselves + 7 fallback pairs from the 6 fallback rules in k8s/llm/gateway/config.yaml.

No setting is added, so no ConfigMap rollout is needed. The gateway fallback is not changed: a person decides.

Live call (one call, cap 1 USD, run once): a tiny structured call with output_type through the gateway with get_tier_model("claude-sonnet-5-5").

  • Model profile: supports_forced_tool_choice = False.
  • The call returned the structured output (word='ok'): a tool call under tool_choice auto.
  • Answered model, response.model of the reply: claude-sonnet-5-5 (no DeepSeek). This is the plain form of the name, with no provider prefix or date suffix, so the fallback test is exact.
  • Gateway record: the gateway keeps no spend log database (store_model_in_db: false), and its /spend/logs routes answer 404. The spend record is the Prometheus series of the gateway. It shows one new series with model="claude-sonnet-5-5", requested_model="claude-sonnet-5-5", api_provider="anthropic", end_user="devops-cli", user_agent="devops-cli/0.98.0", 430 tokens and spend 0.001244 USD. The series is from this one call, matched by its token count and caller. Spend of the call: about 0.0012 USD.
  • Before the fix, the same gateway counted litellm_deployment_successful_fallbacks_total from claude-sonnet-5-5 to deepseek-v4.1-flash-1017 with Anthropic.BadRequestError 400 (about 25 in the last 30 minutes, from other callers that run the old code).

@dan-petty
dan-petty marked this pull request as ready for review November 9, 2026 06:27
@dan-petty
dan-petty merged commit 5c4cabf into main Nov 9, 2026
65 of 77 checks passed
@dan-petty
dan-petty deleted the fix/4205-claude-forced-tool-choice-fallback branch November 9, 2026 09:45
dan-petty pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.100.0](v0.99.0...v0.100.0)
(2026-11-09)


### Features

* **roadmap:** record the reference hits of a stage case in the replay
([#4211](#4211))
([06a7251](06a7251))


### Bug Fixes

* **roadmap:** accept a null reason on a stage reference
([#4215](#4215))
([ce96397](ce96397))
* **roadmap:** count the tokens of each implement Job once
([#4213](#4213))
([a243c25](a243c25))
* **roadmap:** send tool choice auto to Claude and count answers
([#4216](#4216))
([5c4cabf](5c4cabf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Nov 9, 2026
An agent run on a hosted gateway group is recorded as local spend at $0
(#3665). `record_run_spend` in `src/devops_cli/roadmap/agent_run.py`
writes one record per run. When no reply names a model, the record has
no `served_by` and no `served_model`, and `is_local` then decides from
the gateway host: a gateway that is the cluster host is local. The
production counter of job `roadmap-service` on 2026-11-09 shows 68 M
`claude-sonnet-5-5` prompt tokens as `local=true` at $0, while the
gateway log prices them at $2 per million. The DeepSeek group shows $0
on the counter against $14 on the gateway. #3663 fixed a reply that
names a model, and #4216 passes the model that a reply names. A run
whose replies name no model is still wrong.

Closes #3665

Change:
`openspec/changes/archive/2026-11-09-3665-an-agent-run-on-a-hosted/`
dan-petty added a commit that referenced this pull request Nov 9, 2026
…4260)

The stage job kept only the last problem of a refused reply and kept no
refused reply, so a failed plan could not be read. A reply of
placeholders in every text also used the second request and gave the
same reply. The job now logs each refused reply with the request number,
the input tokens and the tool offer, keeps the first and second refused
reply with their problems in a file beside the plan file until the item
is staged, and ends a placeholder reply at once as the new result
degenerate (metric and stage eval). Other changes removed the causes of
the placeholder replies: #4215, #4216, #4224, #4238 and #4243.

Closes #4204

Change:
`openspec/changes/archive/2026-11-09-4204-keep-refused-stage-reply/`
dan-petty added a commit that referenced this pull request Nov 12, 2026
An agent run on a local gateway group, such as devops-coder, recorded
its tokens as hosted: local=false, the pricing source unknown at 0 USD,
and the warning for an unpriced hosted model. The reply of the run names
the group that answered, and is_local made each gateway reply that names
a model hosted (#3656). is_local decides a gateway reply with no backend
by the model that it names: a local gateway group
(CONST_AI_GATEWAY_VIRTUAL_MODELS) or an ollama: model is local, and each
other model, a hosted group included, stays hosted. When the reply names
no model, the asked model decides when it is a local tier.
calculate_request_cost gives is_local the asked model. So a fallback is
priced and labeled at the group that answered (#4216). A local group
outside the constant and the Ollama model of a local fallback stay
hosted: #4886.

Closes #4523

Change:
`openspec/changes/archive/2026-11-12-4523-an-agent-run-on-a-local/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): remove the cause of placeholder stage replies

1 participant