-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(core): ensure tool_choice maps to structured object for AWS Bedrock compliance #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -349,6 +349,15 @@ async def _run_cycle( # noqa: PLR0912, PLR0915 | |||||||||
| while True: | ||||||||||
| try: | ||||||||||
| await coordinator.mark_running(agent_id) | ||||||||||
|
|
||||||||||
| # --- PRODUCTION FIX FOR AWS BEDROCK TOOL_CHOICE COMPLIANCE --- | ||||||||||
| if hasattr(run_config, "extra_body") and isinstance(run_config.extra_body, dict): | ||||||||||
| if "tool_choice" in run_config.extra_body: | ||||||||||
| run_config.extra_body["tool_choice"] = {"type": "auto"} | ||||||||||
| elif hasattr(run_config, "tool_choice") and (run_config.tool_choice == "auto" or isinstance(run_config.tool_choice, str)): | ||||||||||
| run_config.tool_choice = {"type": "auto"} | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: strix/core/execution.py
Line: 357-358
Comment:
**Explicit Tool Choice Becomes Auto**
The `isinstance(run_config.tool_choice, str)` branch rewrites every string value to `{"type": "auto"}`. If a caller selects a specific tool by name, the request is changed to automatic selection before `Runner.run_streamed`, so the model can skip the required tool or call a different one.
```suggestion
elif hasattr(run_config, "tool_choice") and run_config.tool_choice == "auto":
run_config.tool_choice = {"type": "auto"}
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||
| # ------------------------------------------------------------- | ||||||||||
|
|
||||||||||
| stream = Runner.run_streamed( | ||||||||||
| agent, | ||||||||||
| input=input_data, | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.