You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
llm.ts: V2 runner dropped V1's 'last step' signal — AI never warned to finalize work #30866
V1 (packages/opencode/src/session/prompt.ts:1349-1350,1461) sends max-steps.txt (which says "CRITICAL - MAXIMUM STEPS REACHED. Do NOT make any tool calls. Respond with text only.") as an assistant message on the last step:
V2 has no equivalent. The AI is never told "this is your last turn." On step 24 (the actual last step), the AI creates tool calls that will never be settled — the session terminates right after. This compounds with bug #3 (hard MAX_STEPS cutoff) to waste the final turn entirely.
Fix: Before the last iteration, inject the max-steps.txt content as a system message.
V2 was missing two things V1 had: (1) the agent's configured step limit was ignored — the runner used a hardcoded MAX_STEPS = 25 instead of agent.steps ?? 25 (see #30865); and (2) the synthetic assistant message from max-steps.txt was never appended to the final LLM request, so the model would emit tool calls on the cutoff step that never get settled.
The fix in packages/core/src/session/runner/llm.ts mirrors V1's pattern: it now resolves the agent's step limit at the top of run() for the for-loop bound, threads a step counter (Ref<number>) so runTurnAttempt can read the current iteration, and appends the max-steps prompt as an assistant message on the final iteration. Both regressions are covered by four new tests in packages/core/test/session-runner.test.ts.
Activity
github-actions commentedon Jun 5, 2026
This issue might be a duplicate of or closely related to existing issues. Please check:
max-steps.txtbehavior described hereIf these are intentionally separate reports, that's fine — just worth cross-linking them.
lexlian commentedon Jun 8, 2026
I fixed the issue with PR #31328.
V2 was missing two things V1 had: (1) the agent's configured step limit was ignored — the runner used a hardcoded
MAX_STEPS = 25instead ofagent.steps ?? 25(see #30865); and (2) the synthetic assistant message frommax-steps.txtwas never appended to the final LLM request, so the model would emit tool calls on the cutoff step that never get settled.The fix in
packages/core/src/session/runner/llm.tsmirrors V1's pattern: it now resolves the agent's step limit at the top ofrun()for the for-loop bound, threads a step counter (Ref<number>) sorunTurnAttemptcan read the current iteration, and appends the max-steps prompt as anassistantmessage on the final iteration. Both regressions are covered by four new tests inpackages/core/test/session-runner.test.ts.