Repository navigation
fix(agent-task): honor caller max_turns over package defaults and report turn-cap stops - #2589
Merged
Merged
Conversation
…ort turn-cap stops Refs #2567
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.
Refs #2567
Problem
run-agent-task.ymlacceptsmax_turns(default 12), but runtime-package tasks never forwarded it to the agent loop. In Extra-Chill/extrachill run 43726379745 the workflow receivedMAX_TURNS: 40, yet the docs agent still stopped at turn 12.succeededwithno_changes.Root cause
.github/scripts/run-agent-task/execute-native-agent-task.mjs:746putsmax_turnsonly on the workload's top level. Thewp-codebox/run-runtime-packagetask input built at:748-770(workflow: agents/chat,input: {prompt, provider, model}) has nomax_turns.packages/cli/src/agent-code.ts:587(normalizeRuntimeTask) passes the caller's limit only insidetask_input. It never puts it in the nestedinput.inputthat the package runs from.WP_Codebox_Runtime_Package_Executor::execute_workflow()(class-wp-codebox-runtime-package-executor.php) callsagents/chatusing that nested input. Because the input has nomax_turns, agents-apiresolve_max_turns()(register-default-agents-chat-handler.php:457) falls back toDEFAULT_MAX_TURNS = 12(:72). That matches the package'smeta.default_max_turns: 12, so the caller's 40 never took effect.WP_Agent_Conversation_Loop(~:470-510) ends a synthesized max_turns budget silently withcompleted: trueand a natural stop. Nothing downstream could tell a capped run from a finished one.Fix
Caller max_turns wins
normalizeRuntimeTasknow copy the caller's positivemax_turnsinto the run-runtime-package chat input. An explicitinput.input.max_turnsis kept as is.agents/chat, in this order:max_turnsmeta.default_max_turnsmetadata.turn_limit(wp-codebox/agent-turn-limit/v1, withsource: caller|package_default|runtime_default).Turn-cap stops are reported
turn_count >= max_turnsand the final turn still issued tool calls (so the model never got a turn to answer), orstop_reason: max_turns.success: false, amax_turns_exceedederror diagnostic, and a canonicalwp-codebox/agent-terminal-result/v1withstatus: max_turns.WP_Codebox_Runtime_Package_Servicepasses that terminal result through to the host.WP_Codebox_Agent_Outcome_Classifieralso reads the turn-limit record, so remediation outcomes reportmax_turns_exceeded.Workflow result
agent-turn-limit-outcome.mjs, written in the same style as fix(agent-task): record runner-workspace apply outcome and upload write evidence #2588'srunner-workspace-apply-outcome.mjs. It projectsagent_turn_limitfrom, strongest signal first:status: failed,terminal_status: max_turns, exit code 1failure: {stage: "agent", code: "max_turns_exceeded", classification: "max_turns", max_turns, turn_count, message}workspace_apply.status: skipped), and verification and publication are skipped.terminal_statusandagent_turn_limit.Tests
tests/agent-task-max-turns.test.ts:--max-turnsinto the runtime-package chat input and keeps an explicit nested value;scripts/php-runtime-package-max-turns-smoke.phpcovers:agents/chatover the package default of 12;max_turnsterminal result;tests/execute-native-agent-task-lifecycle.test.mjs:max_turnsreaches the runtime-package chat input;max-turnsmode (terminal result) andmax-turns-maintenancemode (the run 43726382831 shape) both fail atstage: agentwithmax_turns_exceeded;terminal_status: max_turns.npm run check: passed (332 commands).AI assistance: Extra Chill Bot (Claude), via a Roadie subagent.