fix: reasoning models reject tool_choice=required; bump to 1.0.2 (closes #503, #505) (#508)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Ahmed Allam
2026-05-28 11:55:10 -07:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 3bd9d56814
commit d0321510d2
5 changed files with 33 additions and 5 deletions
+8 -2
View File
@@ -109,13 +109,19 @@ def build_scope_context(scan_config: dict[str, Any]) -> dict[str, Any]:
def make_model_settings(
reasoning_effort: ReasoningEffort | None,
) -> ModelSettings:
# Anthropic + DeepSeek thinking reject ``tool_choice="required"`` outright
# when reasoning is enabled; OpenAI o-series accepts both but doesn't need
# the safety net. When reasoning is on we let the model self-select tools
# and rely on the system prompt + the ``_finish_tool_use_behavior`` callback
# to keep the loop converging on a lifecycle tool.
use_reasoning = reasoning_effort is not None and reasoning_effort != "none"
model_settings = ModelSettings(
parallel_tool_calls=False,
tool_choice="required",
tool_choice=None if use_reasoning else "required",
retry=DEFAULT_MODEL_RETRY,
include_usage=True,
)
if reasoning_effort is not None:
if use_reasoning:
model_settings = model_settings.resolve(
ModelSettings(reasoning=Reasoning(effort=reasoning_effort)),
)