Repository navigation
fix(agent): gate tool execution on completed status and make forced tool_choice one-shot - #46
Open
alexb-openrouter wants to merge 1 commit into
Open
alexb-openrouter wants to merge 1 commit into
alexb-openrouter wants to merge 1 commit into
Conversation
…ool_choice one-shot
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
This branch has not been deployed
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.
Summary
Fixes two tool-loop execution bugs in
ModelResult(src/openrouter_agent/model_result.py):ModelResult._runpreviously extracted and executed tool calls without checkingresponse.status. It now only extracts tool calls whenget_field(response, "status") == "completed", stopping the loop without running tools, approval gates, or follow-up turns forincomplete(max_output_tokens,content_filter),failed,cancelled,in_progress,queued, or missing-status responses.tool_choiceone-shot across follow-up turns:_build_followup_requestpreviously carried a specific forcedtool_choice/toolChoice(e.g.{"type": "function", "name": "..."},OpenAIResponsesToolChoiceFunction, or named server-tool choices) into subsequent turns after the tool already executed. Forced specific tool choices are now stripped on follow-up turns unless explicitly re-set vianext_turn_params. Non-specific modes ("auto","none","required", and{"type": "allowed_tools", ...}) are preserved.Testing
tests/unit/test_non_completed_response_tools.pycovering non-completed statuses, streamedresponse.incompleteevents, approval/final-response paths, and multi-turn runs.tests/unit/test_forced_tool_choice_one_shot.pycovering snake_case/camelCase/Pydantic forced choices,next_turn_paramsoverrides, and preserved non-specific modes.ruff check .,ruff format --check .,mypy src tests, andpytest tests/unit --cov --cov-fail-under=83(195 passed, 85.33% coverage).