Skip to content

refactor(llm): one tool-schema converter per provider wire format (Anthropic, OpenAI function-tool) with a single-source guard (#16815) - #21816

Merged
mrveiss merged 13 commits into
mainfrom
issue-16815-llm-provider-formatting
Nov 19, 2026
Merged

mrveiss merged 13 commits into
mainfrom
issue-16815-llm-provider-formatting

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

This PR was opened for an existing branch that never had one (triage status UNFINISHED). The branch carries 1ahead commit(s) of work not on main, linked to #16815 (Consolidate duplicated per-provider LLM message/tool-schema formatting). It still needs a conflict sync with main and a review before it can merge. Acceptance criteria have not been verified against this branch.

What Changed

Commits on the branch (not on main):

Diff summary: 11 files changed, 439 insertions(+), 110 deletions(-)

Verification

Not yet verified. No CI evidence: this is a draft; no CI has run on it yet, and it needs a conflict sync with main and a review first.

Model Used

Branch authored by earlier Claude sessions; PR opened by Claude Sonnet 5.5.

Refs #16815

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Standardised how tool definitions are formatted for supported AI providers. Existing request formats and tool-choice behaviour remain unchanged, so users should see no changes when interacting with these integrations.
  • Tests
    • Added checks to confirm provider requests preserve existing tool definitions and behaviour across supported integrations.

@mrveiss mrveiss added the phase:M4.6 Shared primitives in one place label Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4749162 and a009c7a.

Files selected for processing: 12

  • autobot-backend/llm_shared/providers/anthropic.py
  • autobot-backend/llm_shared/providers/bedrock.py
  • autobot-backend/llm_shared/providers/message_formatting.py
  • autobot-backend/llm_shared/providers/message_formatting_test.py
  • autobot-backend/llm_shared/providers/mistral.py
  • autobot-backend/llm_shared/providers/ollama.py
  • autobot-backend/llm_shared/providers/openai_compatible.py
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_policy_verdicts_n_to_z.py
  • repo_tests/_reach_roots_record.py
  • repo_tests/provider_tool_schema_single_source_16815_test.py
  • repo_tests/reach_scope_claim_17844_test.py
Walkthrough

Provider request builders now use shared functions to format Anthropic and OpenAI function-tool schemas. Tests check formatted payloads against frozen expectations and scan provider sources for inline schema definitions.

Changes: Provider tool-schema formatting

Layer / File(s) Summary
Shared converters and provider integration
autobot-backend/llm_shared/providers/message_formatting.py, autobot-backend/llm_shared/providers/{anthropic,bedrock,mistral,ollama,openai_compatible}.py, autobot-backend/llm_shared/providers/message_formatting_test.py
Adds shared Anthropic and OpenAI function-tool schema converters. Anthropic, Bedrock, Mistral, Ollama and OpenAI-compatible request builders use the converters. Tests compare formatted output and provider payloads with frozen expectations.
Inline-schema scan and scope registration
repo_tests/provider_tool_schema_single_source_16815_test.py, repo_tests/_reach_declared_scopes.py, repo_tests/_reach_policy_verdicts_n_to_z.py, repo_tests/reach_scope_claim_17844_test.py
Adds an AST-based scan for inline tool-schema definitions in provider sources. Registers the scan scope and its reach policy.
Merge Risk: Moderate · previous review 47491

The new provider payload tests cannot be collected because of a wrong import, and the reach scope-claim test fails because the recorded roots differ from the registered ones. Both are small fixes, and no runtime behavior problem was found. Fix them so CI passes before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the refactor of tool-schema formatting into one converter per provider wire format (Anthropic and OpenAI function-tool), plus a single-source guard. The changeset matches this: new con…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the refactor of tool-schema formatting into one converter per provider wire format (Anthropic and OpenAI function-tool), plus a single-source guard. The changeset matches this: new converters in message_formatting.py, providers switched to use them, and a repo test that scans for inlined schemas. The title is long and lists two items, but it refers to the primary change and is not misleading.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor

Auto-sync: merging main into issue-16815-llm-provider-formatting conflicts

The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 38c62a97b8. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.

autobot-backend/llm_shared/providers/anthropic.py

side commit subject issue refs
main 224a92a239 fix(llm): resolve the Claude SSOT review findings and merge main (#20884) #20884
main 04600d11dd fix(models): one definition for current prices and Claude context windows, drop the interleaved beta on conversion (#20884) #20884
main 7b10163b3c fix(models): import the Claude-ID SSOT at the top of the Anthropic provider (#20884) #20884
main 3f9285e829 fix(models): adaptive thinking by default, legacy-ID hires, current pricing fallback and chains (#20884) #20884
main f787befcb3 fix(models): keep legacy fallback-chain names working and read the defaults from the SSOT (#20884) #20884
main 0444f472c7 refactor(llm): one provider x tier table for hosted default models; every provider resolves through it with a {PROVIDER}_DEFAULT_MODEL override; OpenRouter and Bedrock off their stale defaults; catalogs use the SSOT names (#15501, #18210) #15501, #18210
main 29c6f90ae4 fix(llm-auth): LLM calls use the signed-in token — the user's own, then the system one, then the API key (#19241) #19241
main a44a310265 refactor(llm): one Anthropic-family message formatter shared by the anthropic and vertexai providers (#16815) #16815
main 6ddbd65e00 feat(llm): needs_reauth registry skip + typed error, header headroom harvest, pre-dispatch headroom routing (#15022, #15026, #15028) #15022, #15026, #15028
this branch 38527c5369 refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) #16815

autobot-backend/llm_shared/providers/bedrock.py

side commit subject issue refs
main 0444f472c7 refactor(llm): one provider x tier table for hosted default models; every provider resolves through it with a {PROVIDER}_DEFAULT_MODEL override; OpenRouter and Bedrock off their stale defaults; catalogs use the SSOT names (#15501, #18210) #15501, #18210
main a44a310265 refactor(llm): one Anthropic-family message formatter shared by the anthropic and vertexai providers (#16815) #16815
this branch 38527c5369 refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) #16815

autobot-backend/llm_shared/providers/vertexai.py

side commit subject issue refs
main 0444f472c7 refactor(llm): one provider x tier table for hosted default models; every provider resolves through it with a {PROVIDER}_DEFAULT_MODEL override; OpenRouter and Bedrock off their stale defaults; catalogs use the SSOT names (#15501, #18210) #15501, #18210
main a44a310265 refactor(llm): one Anthropic-family message formatter shared by the anthropic and vertexai providers (#16815) #16815
this branch 38527c5369 refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) #16815

repo_tests/_reach_policy.py

side commit subject issue refs
main a471e4d87e test(i18n): a shrink-only ratchet on hard-coded English UI text, per file (#12732) #12732
main 091af388da fix(api): register literal routes ahead of the {param} routes that captured them (#18720) #18720
main b10b96593b fix(config): floor the env-family guard's reach and declare its filter widening (#18555) #18555
main 246b86f9ee test(train): record why #18641's backoff-formula-scan allowance is absolute (#15402) #18641, #15402
main 8ba19f55b0 Merge #18626 @ 514e49b into train-2026-10-17-22b #18626
main a44a310265 refactor(llm): one Anthropic-family message formatter shared by the anthropic and vertexai providers (#16815) #16815
main 547f376ebb refactor(resilience): the circuit breaker moves to autobot_shared behind a backend shim; a guard stops new hand-rolled breakers (#18554) #18554
main a388889be4 Merge #18612 @ af1ff7e into train-2026-10-16-20 #18612
main 8864e0c436 fix(slm): node enrollment deploys the real agent through the slm_agent role; the inline stand-in agent and string-embedded playbook are gone (#18606) #18606
main 383ea8c375 refactor(redis): a guard freezes today's direct Redis constructors; the terminal and timeout callers use the canonical client (#18553) #18553
main 8251c2087f Merge #18595 @ a600d2a into train-2026-10-16-17b #18595
main 0be6ce0c6a Merge #18591 @ 5f94ace into train-2026-10-16-17b (hub union: reach policy) #18591
main a600d2afc0 refactor(backend): retire 8 compatibility facades; importers use the canonical modules (#18552) #18552
main aaeb648337 refactor(data): one copy of each static data file (#18556) #18556
main 960fa5086c refactor(browser): one playwright-server.js; drop the unreferenced backup compose (#18549) #18549
main 96 more commit(s) not listed
this branch 38527c5369 refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) #16815

repo_tests/reach_scope_claim_17844_test.py

side commit subject issue refs
main be5b2b0be2 test(guards): one compare-and-delete script, the shape matched with recorded exceptions and a planted-copy control (#19631) #19631
main fe97219e8c Merge origin/main into issue-21078-test-filenames (#21078) #21078
main 5d6c08c7eb refactor: move the reach scope record to its own module and register the test-name guard (#21078) #21078
main eb0ccc38fc Merge main into issue-20761-api-key-compare (auto-sync) [skip ci] none
main 464269b063 fix(train): reach floor follows the merged tree; scope-claim test stays under the 600-line cap (#17844) #17844
main 8019cce84d Merge branch 'main' into train-2026-11-07-t91 none
main 1fd6964fd3 fix(auth): the constant-time compare guard declares its reach floor, scope and roots (#20761) #20761
main 25b8798246 Merge #20969 @ b9c58d0 into the merge train #20969
main c16ff8bae0 Merge #20893 @ 1658109 into the merge train #20893
main 74816fa315 fix(deploy): record the venv-builder guard's declared scope in both reach records (#20932) #20932
main 982e6998ff merge: origin/main into issue-20889-snapshot-cleanup; route #20478 sites through accessors (#20889) #20478, #20889
main a35719e02d Merge main into issue-20046-ssh-password-proposal (auto-sync) [skip ci] none
main c09459f5d8 fix(snapshots): record the inline-lazy_singleton guard's scope and floor (#20889) #20889
main ab55d41295 Merge main into issue-20046-ssh-password-proposal none
main 2b2f7e52f4 Merge main into issue-20512-unconnected-code-gate (auto-sync) [skip ci] none
main 311 more commit(s) not listed
this branch 38527c5369 refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) #16815

@github-actions github-actions Bot added the sync-conflict Set by the branch sync (#19548) label Nov 18, 2026
@mrveiss mrveiss changed the title refactor(llm): one formatter per provider wire format, Claude-on-Vertex and Bedrock share the Anthropic splitter (#16815) refactor(llm): one tool-schema converter per provider wire format (Anthropic, OpenAI function-tool) with a single-source guard (#16815) Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f0a3255 and 4749162.

Files selected for processing: 11

  • autobot-backend/llm_shared/providers/anthropic.py
  • autobot-backend/llm_shared/providers/bedrock.py
  • autobot-backend/llm_shared/providers/message_formatting.py
  • autobot-backend/llm_shared/providers/message_formatting_test.py
  • autobot-backend/llm_shared/providers/mistral.py
  • autobot-backend/llm_shared/providers/ollama.py
  • autobot-backend/llm_shared/providers/openai_compatible.py
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_policy_verdicts_n_to_z.py
  • repo_tests/provider_tool_schema_single_source_16815_test.py
  • repo_tests/reach_scope_claim_17844_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread repo_tests/_reach_declared_scopes.py Resolved
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
@github-actions github-actions Bot removed the sync-conflict Set by the branch sync (#19548) label Nov 19, 2026
@mrveiss
mrveiss merged commit f98f24e into main Nov 19, 2026
65 checks passed
@mrveiss
mrveiss deleted the issue-16815-llm-provider-formatting branch November 19, 2026 10:01
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M4.6 Shared primitives in one place

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant