Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions strix/core/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Comment thread
toshalkumbhar8979-design marked this conversation as resolved.

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.

P1 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.

Suggested change
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"}
elif hasattr(run_config, "tool_choice") and run_config.tool_choice == "auto":
run_config.tool_choice = {"type": "auto"}
Prompt To Fix With AI
This 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,
Expand Down