fix(conversation): send tool_choice to anthropic as obj not str- #4531 - #4543
Open
sicoyle wants to merge 38 commits into
Open
fix(conversation): send tool_choice to anthropic as obj not str- #4531#4543sicoyle wants to merge 38 commits into
sicoyle wants to merge 38 commits into
Conversation
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sam <sam@diagrid.io>
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Albert Callarisa <albert@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
dapr#4227) Signed-off-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Nemanja Malocic <n.malocic@vegait.rs> Signed-off-by: Nemanja Malocic <coderns@gmail.com> Signed-off-by: Mike Nguyen <hey@mike.ee> Co-authored-by: Nemanja Malocic <n.malocic@vegait.rs> Co-authored-by: Elena Kolevska <elena-kolevska@users.noreply.github.com> Co-authored-by: Cassie Coyle <cassie@diagrid.io> Co-authored-by: Mark Fussell <markfussell@gmail.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Co-authored-by: Yaron Schneider <schneider.yaron@live.com> Co-authored-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…4228) Signed-off-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Co-authored-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
The `example` field in the component metadata schema must always be a string. The `defaultDaprPort` field had an unquoted integer value (3500) which caused the bundle-component-metadata build tool to panic with: json: cannot unmarshal number into Go struct field Metadata.metadata.example of type string Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
TestPostgresConfigurationWithIAM uses testcontainers to spin up moto and PostgreSQL containers. On macOS CI runners without Docker, the call to GenericContainer panics with "rootless Docker not found" instead of gracefully skipping. Add testcontainers.SkipIfProviderIsNotHealthy(t) at the top of the test so it is skipped cleanly when no container runtime is available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Windows Docker runs in Windows-container mode and does not ship the bridge network plugin, so testcontainers fails with: could not find plugin bridge in v1 plugin registry: plugin not found Add an explicit runtime.GOOS check to skip the test on Windows, similar to the existing SkipIfProviderIsNotHealthy guard added for macOS runners. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Use runtime.GOOS != "linux" to skip the test on macOS and Windows. testcontainers requires the Docker bridge network plugin which is only reliably available on Linux runners. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Jose Maria Flores Zazo <jmfloreszazo@gmail.com> Co-authored-by: Jose María Flores Zazo <jmfloreszazo@outlook.com> Co-authored-by: Yaron Schneider <schneider.yaron@live.com> Co-authored-by: Nelson Parente <nelson_parente@live.com.pt> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…f HTTP 500 (dapr#4243) Signed-off-by: nelson.parente <nelson_parente@live.com.pt> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
… publishing (dapr#4244) Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
… langchaingokit LLM logger (dapr#4270) Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Luis Rascao <luis.rascao@gmail.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
dapr#4290) Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: Josh van Leeuwen <me@joshvanl.dev> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
….2.3 to v23.2.29 (dapr#4294) Signed-off-by: Javier Aliaga <javier@aliaga.dev> Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
… required (dapr#4293) Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: Cassie Coyle <cassie.i.coyle@gmail.com> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…Pulsar Pubsub (dapr#4323) Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…harden graceful shutdown (dapr#4370) Signed-off-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> Co-authored-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…ount-based bulk flush (dapr#4379) Signed-off-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> Co-authored-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…s to prevent subscription disruption on restart (dapr#4332) Signed-off-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> Co-authored-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Mike Nguyen <hey@mike.ee> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Samantha Coyle <sam@diagrid.io>
…orkflow runs (dapr#4507) Signed-off-by: Samantha Coyle <sam@diagrid.io>
dapr#4529) Signed-off-by: Samantha Coyle <sam@diagrid.io> Signed-off-by: Sam <sam@diagrid.io> Co-authored-by: Sam <sam@diagrid.io> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
…thout a JWT SVID source (dapr#4527) Signed-off-by: MyMirelHub <15373565+MyMirelHub@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Samantha Coyle <sam@diagrid.io>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sam <sam@diagrid.io> Signed-off-by: Samantha Coyle <sam@diagrid.io>
Signed-off-by: Samantha Coyle <sam@diagrid.io>
….com:sicoyle/components-contrib into samcoyle/cat-1448-anthropic-bug-release-1.17
Contributor
There was a problem hiding this comment.
Pull request overview
This PR backports a fix to the conversation LangChain-Go adapter so Anthropic requests serialize tool_choice in the object form required by Anthropic’s Messages API (instead of forwarding the provider-agnostic string verbatim), while keeping other providers’ behavior unchanged.
Changes:
- Introduces provider-aware translation for
ToolChoice, including omitting it when Anthropic has no tools and mappingrequired/any/none/named-toolinto Anthropic’s expected object shape. - Plumbs a
Provideridentifier through the LangChain-Go LLM wrapper and sets it for the Anthropic component. - Adds unit tests for tool choice translation and conformance coverage for explicit tool choice usage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/conformance/conversation/conversation.go | Adds conformance subtests for explicit ToolChoice values (including Anthropic-specific named tool choice). |
| conversation/langchaingokit/translate.go | Adds translateToolChoice to convert provider-agnostic tool choice strings into provider-specific wire formats (Anthropic object form). |
| conversation/langchaingokit/translate_test.go | Adds unit tests for tool choice translation + updates option-building tests to be provider-aware. |
| conversation/langchaingokit/model.go | Adds Provider to the LLM wrapper and applies tool choice translation when building LangChain call options; treats any like required for tool-call enforcement. |
| conversation/langchaingokit/model_test.go | Extends existing empty-response-with-tools tests to cover tool_choice=any. |
| conversation/anthropic/anthropic.go | Sets the provider to Anthropic so translation is applied for Anthropic requests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+438
to
+459
| for _, toolChoice := range toolChoices { | ||
| t.Run(toolChoice, func(t *testing.T) { | ||
| ctx, cancel := context.WithTimeout(t.Context(), 25*time.Second) | ||
| defer cancel() | ||
|
|
||
| messages := []llms.MessageContent{ | ||
| { | ||
| Role: llms.ChatMessageTypeHuman, | ||
| Parts: []llms.ContentPart{ | ||
| llms.TextContent{Text: "What is this open source project called?"}, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| req := &conversation.Request{ | ||
| Message: &messages, | ||
| Tools: &tools, | ||
| ToolChoice: &toolChoice, | ||
| } | ||
| if component == "openai" { | ||
| req.Temperature = 1 | ||
| } |
Comment on lines
+298
to
+311
| "non-anthropic provider passes the bare string through": { | ||
| toolChoice: "required", | ||
| hasTools: true, | ||
| expected: "required", | ||
| }, | ||
| "non-anthropic provider passes a named tool through": { | ||
| toolChoice: "get_weather", | ||
| hasTools: true, | ||
| expected: "get_weather", | ||
| }, | ||
| "non-anthropic provider passes through without tools": { | ||
| toolChoice: "required", | ||
| expected: "required", | ||
| }, |
tthophan
approved these changes
Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
manual 1.17 backport to fix conflicts on the autogenerated backport
#4531
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list:
Note: We expect contributors to open a corresponding documentation PR in the dapr/docs repository. As the implementer, you are the best person to document your work! Implementation PRs will not be merged until the documentation PR is opened and ready for review.