Repository navigation
pi: skip Oh My Pi request-control system rows in the dispatch check - #786
Merged
ualtinok merged 1 commit intoOct 26, 2026
Merged
Conversation
Oh My Pi's Anthropic provider (insertAnthropicControlMarkers in pi-ai/src/providers/anthropic.ts, 18.12.6) appends request-control system messages while it builds the request: tool_addition/tool_removal blocks when the session's recorded tool set differs from the current one, and empty effort-only controls. That happens after the context pass, so the prepared plan never contains them. payloadStructure skipped system/developer messages only before the first conversation row, so a trailing control was counted as an extra row and every turn was refused with "prepared turn structure ... expectedRole=missing actualRole=system comparison=count". Oh My Pi records the control only after a successful request, so an affected session could never recover on its own. Skip system messages whose content consists only of tool_addition or tool_removal blocks (an empty array included). System rows carrying any other content are still counted and compared, so an unprepared system text row keeps refusing. Refs cortexkit#785
|
#785 has the |
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.
Approved issue: #785
Harness coverage (required)
For each entry select: covered / not applicable — surface does not exist there / NOT covered.
packages/pi-plugin/src/pi-dispatch-structure.ts; no equivalent inpackages/plugin)payloadStructurecode path; Pi's providers do not emit these control rows, so its behavior is unchanged)crates/)What and why
Oh My Pi's Anthropic provider (
insertAnthropicControlMarkersinpi-ai/src/providers/anthropic.ts, 18.12.6) appends request-controlsystemmessages while it builds the request:tool_addition/tool_removalblocks when the session's recorded tool set differs from the current one, and empty effort-only controls (content: []). This happens after the context pass, so the prepared plan never contains them.payloadStructureskippedsystem/developermessages only before the first conversation row, so a trailing control was counted as an extra row and every turn was refused withprepared turn structure ... expectedRole=missing actualRole=system comparison=count. Oh My Pi records the control only after a successful request, so an affected session could never recover on its own.The fix skips
systemmessages whose content is an array made only oftool_addition/tool_removalblocks (an empty array included). A system row carrying any other content (a string, a text block, or a control mixed with text) is still counted and compared, so unprepared system text keeps refusing.Tests
New
packages/pi-plugin/src/issue-785-request-controls.test.ts:tool_additioncontrol, a mixedtool_addition+tool_removalcontrol, or an empty effort-only control has no mismatch against the plan without it. Without the fix this fails withrow=4 expectedRows=4 actualRows=5 expectedRole=missing actualRole=system ... comparison=count, the reported refusal.Ran in
packages/pi-plugin:bun test src/issue-785-request-controls.test.ts src/issue-686-midhistory-system.test.ts src/issue-686-system-head.test.ts src/pi-dispatch-structure-diagnostic.test.ts: 20 pass, 0 fail.bun run typecheck: clean.bunx biome checkon both changed files: clean.bun run test: 3483 pass, 53 skip, 7 fail. The same 7 (index-env-guard,tag-snapshot-hydration-pi,context-handler-lkg-debug-assertions,lkg-fence-restart-regressionx3,held-head-replay-witness) also fail on unmodifiedmasterin this environment.The live behavior was also checked by applying the same change to the published 0.49.23 dist: the previously refused session replies normally and new sessions are unaffected.