Skip to content

fix(agent_loop): resend a refused reasoning-off call with the provider's default - #621

Closed
sanil-23 wants to merge 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/reasoning-off-refused
Closed

sanil-23 wants to merge 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/reasoning-off-refused

Conversation

@sanil-23

Copy link
Copy Markdown
Contributor

Summary

Some provider endpoints cannot run without reasoning. They refuse a request sent with ReasoningEffort::None; OpenRouter relays it as HTTP 400: Reasoning is mandatory for this endpoint and cannot be disabled. That refusal ended the run.

It bites hardest with RunPolicy::truncated_empty_reasoning_off (#510): the call after a dead one goes out with reasoning off, on whichever endpoint a router picks next. A model served by many endpoints has some that refuse, so the recovery call itself killed the run.

  • Seen in: a host's live suite on z-ai/glm-5.3-flash through OpenRouter. 8 of 42 agent runs in one pass, and 8 in an earlier pass, ended with this error after two or three good steps.
  • Fix: in invoke_model_resolving, a request that turns reasoning off and is refused for that reason goes out once more with reasoning: None, so the provider's own default applies. This covers the unary and the streaming path, and any caller that set ReasoningEffort::None, not only the dead-call recovery.
  • Not a retry: the resend is not counted against RunPolicy::retry, emits no RetryScheduled, and cannot repeat, because the resent request no longer turns reasoning off.
  • How the refusal is recognised: by its message (reasoning together with mandatory, cannot be disabled or can't be disabled), on a Provider or plain Model error, and only when the request itself had ReasoningEffort::None. No provider gives this refusal a code of its own; classify_provider_failure reads messages the same way.

API Or Behavior Changes

Behavior: a reasoning-off request refused as above is resent with the provider's reasoning default instead of failing. A caller that asked for no reasoning gets reasoning on such an endpoint, with a warn! logged; the alternative was no answer at all. No public API change.

Tests

New agent_loop/model_call_reasoning_refused_tests.rs:

  • a refused reasoning-off call is sent again with the provider's default;

  • another 400 on a reasoning-off call still fails, with one attempt;

  • a call that keeps its reasoning is sent once;

  • only a reasoning-off request refused for that reason counts (plain Model error, Provider error, a request that asked for reasoning, an unrelated message, a non-model error).

  • cargo fmt --check

  • cargo clippy --workspace --all-targets -- -D warnings

  • cargo clippy --all-targets --all-features -- -D warnings: not run

  • cargo build --all-targets: not run on its own; clippy built all targets

  • cargo build --all-targets --all-features: not run

  • cargo test: cargo test -p tinyagents-harness ran: 3336 passed, 3 failed. The 3 are providers::claude_code::driver tests that execute a stand-in claude script from a temp directory, which this machine's sandbox refuses ("Operation not permitted"). They do not touch this change. The other crates' tests were not run.

  • cargo test --all-features: not run

Not covered: no live run against a refusing endpoint. Which endpoint refuses is the router's choice per call, so it cannot be reproduced on demand.

Documentation

crates/tinyagents-harness/src/agent_loop/README.md (after the reasoning-off controls) and an Unreleased entry in CHANGELOG.md.

🤖 Generated with Claude Code

…r's default

Some provider endpoints cannot run without reasoning and refuse a request
sent with ReasoningEffort::None ("HTTP 400: Reasoning is mandatory for this
endpoint and cannot be disabled."). The refusal ended the run. With
RunPolicy::truncated_empty_reasoning_off the call after a dead one goes out
with reasoning off on whichever endpoint a router picks, so a run died
whenever that endpoint was one of these.

The refused request now goes out once more with no reasoning setting. It
is not counted as a retry and cannot repeat.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sanil-23

Copy link
Copy Markdown
Contributor Author

Closing: this will be handled by choosing providers that accept reasoning off, so no harness change is needed.

@sanil-23 sanil-23 closed this Nov 22, 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.

1 participant