Skip to content

fix s03: move reminder text block after tool_result blocks#210

Open
tensaPetalum wants to merge 3 commits intoshareAI-lab:mainfrom
tensaPetalum:fix/tool-result-reminder-text-ordering
Open

fix s03: move reminder text block after tool_result blocks#210
tensaPetalum wants to merge 3 commits intoshareAI-lab:mainfrom
tensaPetalum:fix/tool-result-reminder-text-ordering

Conversation

@tensaPetalum
Copy link
Copy Markdown

Problem

When the plan reminder fires, it was inserted at index 0 of the user
message content array before the tool_result blocks. The Anthropic
API requires that when the previous assistant message contained
tool_use blocks, the next user message must begin with tool_result
blocks. Any other content type appearing first causes a 400 error:

tool_use ids were found without tool_result blocks immediately
after: toolu_...

Fix

Change results.insert(0, ...) to results.append(...) so the
reminder text block always follows all tool results.

Reproduction

Run a multi-step task long enough to trigger the reminder interval
(PLAN_REMINDER_INTERVAL = 3 rounds without a todo call). The 400
will fire on the next API call after the reminder is injected.

CrazyBoyM and others added 3 commits April 8, 2026 05:45
The reminder was being inserted at index 0 of the user message
content array, placing it before tool_result blocks. Claude API
requires tool_result blocks to appear before any other content
type when the previous assistant message contained tool_use blocks.

Fix by appending the reminder after tool results instead of
prepending it.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

@tensaPetalum is attempting to deploy a commit to the crazyboym's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tensaPetalum tensaPetalum marked this pull request as ready for review April 11, 2026 03:57
@tensaPetalum tensaPetalum changed the title fix: move reminder text block after tool_result blocks fix s03: move reminder text block after tool_result blocks Apr 11, 2026
@CrazyBoyM CrazyBoyM force-pushed the main branch 2 times, most recently from 36897b1 to d882d01 Compare April 14, 2026 16:11
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.

2 participants