fix(runtime): deliver the history-compact instruction as a trailing user message - #4797
Open
ggbdpq wants to merge 1 commit into
Open
fix(runtime): deliver the history-compact instruction as a trailing user message#4797ggbdpq wants to merge 1 commit into
ggbdpq wants to merge 1 commit into
Conversation
…ser message The history summarizer sent SUMMARIZATION_SYSTEM_PROMPT as provider instructions (system role). Agentic coding models such as kimi k3-256k ignore a system prompt in this shape and keep answering the conversation instead, so mid-turn compaction failed open forever with malformed_summary_missing_section (51 consecutive failed-open decisions observed; 180 history_compact calls and zero checkpoints on one workspace). A distinct system prompt also started the summarizer request outside the main loop's cached prefix, so every discarded attempt paid a full uncached pass (up to 88s observed). Fold the instruction into the trailing user message the request already ends with (apache#4559): generateSummary now appends one user message combining the sectioned prompt (or its shorten/repair variant) with the summary request, and AiSdkGenerateTextOptions drops the instructions field. Fixes apache#4634 Generated-by: GLM-5.3-Flash (ZCode)
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.
Summary
Fixes the root cause of #4634: the history summarizer delivered
SUMMARIZATION_SYSTEM_PROMPTas provider instructions (system role). Agentic coding models such askimi-coding-plan/k3-256kignore that shape and keep answering the conversation, so every fold failed open withmalformed_summary_missing_section, and the distinct system prompt also forfeited the main loop's prefix cache for every discarded summarizer call.The instruction now rides as the request's trailing user message — the request already ended with one for chat-template models (#4559);
generateSummaryappends a single user message combining the sectioned prompt (or its shorten/repair variant) with the existing summary request, andAiSdkGenerateTextOptionsdrops the now-unusedinstructionsfield.Scope: direction 1 from the issue. Of the contributing defects listed there, the missing output cap is already fixed on current
mainby #4653 (DEFAULT_HISTORY_COMPACT_MAX_OUTPUT_TOKENS, landed 09-03, after the reporter's build); extending the failure circuit toprovider_error/output_lengthand bounding the summarizer input budget remain open follow-ups best split into their own issues.Verification
npm --workspace @maka/core run build && npm --workspace @maka/storage run build && npm --workspace @maka/runtime run build, thennode --testonhistory-compact-summarizer/effective-history-compaction/mid-turn-capacity-backenddist testsgit stash push -- packages/runtime/src/history-compact-summarizer.ts, rebuild, rerun the summarizer suitedelivers the summarization instruction as the trailing user message (#4634)instructionsfield reachesgenerateTextand the final user message carries both the sectioned prompt and the summary requestnpm run format:checknpm run check:asf-headersAI use
Implemented with ZCode (GLM-5.3-Flash): read the issue's reproduction data, traced the summarizer request shape in
packages/runtime/src/history-compact-summarizer.ts, and made the minimal request-shape change with a red-green regression test. The commit carries theGenerated-bytrailer.Checklist
node:test+assert/strict, issue number in the test name)