Repository navigation
Conversation
anujbolewar
left a comment
There was a problem hiding this comment.
Thanks — this is the right fix. I traced it: toOaCompatibleRequest reads the flat tool.name / tool.description / tool.parameters off the CommonRequest, but the old fromAnthropicRequest was nesting them again under function: { ... }, so on the anthropic -> oa-compat path the converter saw name: undefined and silently dropped it. Dropping the redundant wrapper aligns the shape with what toOaCompatibleRequest actually consumes.
The test is well-targeted — asserting the name and parameter survive on the oa-compat output is exactly what the bug required.
One thing worth confirming (non-blocking): this same fromAnthropicRequest output is passed through unchanged for anthropic -> anthropic (the converter only rewrites when to === "oa-compat"). Just want to be sure the flat shape is what the Anthropic endpoint expects on the wire, since it natively wants input_schema rather than parameters. Fine for the oa path either way.
|
Thanks for tracing that — that matches what I saw. I confirmed the direct Anthropic path is not rewritten through the common shape: The flat |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Fixes #41120
Type of change
What does this PR do?
Fixes the Anthropic
/messages→ OpenAI-compatible/chat/completionsconversion for tool definitions.fromAnthropicRequest()now converts Anthropic tools into the common tool shape (name,description,parameters) instead of an OpenAI nestedfunctionshape. This preserves tool names when the downstream provider is OpenAI-compatible, avoiding an emitted request with an undefined function name.How did you verify your code works?
bun test ./test/providerUsage.test.ts --test-name-pattern 'preserves Anthropic tool names'bun typecheckinpackages/console/appbun run lint packages/console/app/src/routes/zen/util/provider/anthropic.ts packages/console/app/test/providerUsage.test.tsgit diff --checkNote: the wider
bun test ./test/providerUsage.test.tscurrently has two pre-existing Google usage expectation failures onoutputTokens(expected 3, received 5) unrelated to this diff. The focused regression above passes.Also note: repo-wide pre-push typecheck is currently blocked by an existing
@opencode-ai/enterprise/src/custom-elements.d.tsparse error unrelated to this diff, so I pushed with--no-verifyafter the focused checks passed.Screenshots / recordings
Not a UI change.
Checklist