Description
File: packages/core/src/session/runner/llm.ts:256
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:
const maxSteps = agent.steps ?? Infinity
const isLastStep = step >= maxSteps
// L1461:
messages: [...modelMsgs, ...(isLastStep ? [{ role: "assistant", content: MAX_STEPS }] : [])],
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.
OpenCode version
v1.16.0 (commit 3cf1cef)
Description
File:
packages/core/src/session/runner/llm.ts:256V1 (
packages/opencode/src/session/prompt.ts:1349-1350,1461) sendsmax-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.
OpenCode version
v1.16.0 (commit 3cf1cef)