Skip to content

fix(provider): fall back to auto tool choice when forced is rejected - #261

Draft
johnandersen777 wants to merge 1 commit into
graze-social:mainfrom
johnandersen777:fix/tool-canary-auto-fallback
Draft

johnandersen777 wants to merge 1 commit into
graze-social:mainfrom
johnandersen777:fix/tool-canary-auto-fallback

Conversation

@johnandersen777

@johnandersen777 johnandersen777 commented Nov 30, 2026 •

Copy link
Copy Markdown

Problem

Some OpenAI-compatible servers reject a forced tool_choice while supporting automatic tool calls. The tool canary only tried forced, so such servers were registered without tool support. Even after an auto pass, job requests forwarded forced/required choices and failed upstream.

Fix

  • Tool canary: if the forced attempt returns an HTTP/transport error, retry once with tool_choice: "auto" and a neutral system prompt. Advertise only when either probe returns a valid report_status call.
  • Job requests on an auto-verified engine rewrite required/named forced choices to auto; omitted stays omitted; none is sent without tools or tool_choice.

Verification

  • cargo test --lib — 257 passed
  • cargo clippy --locked --all-targets --all-features -- -D warnings — clean
  • cargo fmt --check — clean
  • Unit: forced-rejected → auto passes; auto prose/error → not advertised; rewrite matrix (object/required/any/none/auto/absent, forced-OK and unverified no-ops); job downgrade on stream + once paths
  • Live: cocore API → inkling-2-mini, report_status{"status":"ok"} for omitted, auto, required, and forced function choice; none returns no tools
  • Live: pi (direct deno invocation, provider cocore) ran a bash tool call through cocore

Limitations

  • Retry fires only when the forced probe returns an HTTP/transport error; a 200 reply with no tool call leaves tools unadvertised.
  • Auto-only engines rewrite required and named forced choices to auto; callers may receive a different tool call or none.
  • The auto probe replaces the canary system message with a neutral one, so advertisement proves automatic tool calling under a neutral system prompt, not arbitrary system text. Upstreams that reject specific system text with tools can still fail those jobs. Seen live: inkspren errored on one specific sentence; its maintainers reverted a parser "recovery" after concluding the framing had no protocol basis.
  • Tool-choice behavior is verified at startup only; no periodic re-probe.

Merge note

With #259, resolve the shared canary helper to "tool_choice": tool_choice and "max_tokens": 2048.

Draft PR (no issue link).

🤖 Generated with Claude Code

@johnandersen777
johnandersen777 force-pushed the fix/tool-canary-auto-fallback branch 2 times, most recently from a3950de to 844980e Compare November 30, 2026 08:41
Some attached servers reject a forced tool_choice while supporting
automatic calls. The tool canary retries once with tool_choice auto and a
neutral system prompt, and attached jobs rewrite forced/required choices
to auto (none drops tools) when only that probe passed.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@johnandersen777
johnandersen777 force-pushed the fix/tool-canary-auto-fallback branch from 844980e to 28cfe4a Compare November 30, 2026 08:49

This branch has not been deployed

No deployments
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