Skip to content

fix(core): send step-limit instructions as user messages - #56257

Open
HootRock wants to merge 1 commit into
anomalyco:devfrom
HootRock:step-limit-user
Open

HootRock wants to merge 1 commit into
anomalyco:devfrom
HootRock:step-limit-user

Conversation

@HootRock

@HootRock HootRock commented Oct 16, 2026 •

Copy link
Copy Markdown

Issue for this PR

Fixes #56250.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Send the maximum-step instruction as a user message so providers that reject assistant prefill can receive the final summary request. Tool definitions, toolChoice: none, step counting and durable history stay unchanged.

This carries forward the surviving V2 repair from @Anooshiravan's closed, unmerged #34276, with attribution in the commit. The original author explicitly offered that patch for reuse. The existing final-step and retry tests now require the user role.

How did you verify your code works?

Native Windows, Bun 1.4.2, frozen dependencies:

  • The corrected final-step assertion fails on unchanged dev with assistant versus user.
  • All five owning SessionRunner modules pass: 288 tests. Final-step, steering-reset and retry controls pass 30 times with 250 assertions.
  • Four additional offline runner probes at limits 1/2 pass, including Anthropic/OpenAI request-body compilation and unchanged durable history.
  • Core typecheck, scoped lint/format and independent review pass.

The broader core run encounters three Windows failures: symlink creation and two config-discovery assertions; the latter also fail on unchanged dev. Root lint completes, but root typecheck stops at the Windows checkout's textual app/src/custom-elements.d.ts symlink. This is not a whole-repository or live-provider validation.

reviewed and tested locally.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #46415, #53524, #55921

Carry forward the surviving V2 role repair from closed PR anomalyco#34276 for
the current step-cap reproduction in anomalyco#56250. Keep cached tool definitions
and final-step tool selection unchanged, and update retry role controls.

Co-authored-by: Anoosh Ahmadi <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works. I ran the reproduction from #56250 with the simulated model (agent steps: 2). On the base, the step-capped request ends with the MAX_STEPS prompt as an assistant turn. With this change, it ends as a user turn and the model answers with a summary. session-runner.test.ts (229 tests) and the packages/core typecheck pass.

I checked that a user turn right after tool results is still a valid request. Bedrock Converse merges it into the previous user turn, and Anthropic accepts consecutive user turns. Transcripts with queued user input already produce that shape. The edited retry test still checks what it should: the first request must not carry the MAX_STEPS prompt as a user message.

Public API: unchanged.

I have no concerns.

Related: #46415, #53524, #55921

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Step-capped agents fail with an assistant prefill 400

1 participant