fix(agent-harness): keep the compressed window when a steering note is injected - #1815
fix(agent-harness): keep the compressed window when a steering note is injected#1815andyst-dev wants to merge 1 commit into
Conversation
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
🤔 Insufficient Task ContextI found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details. 🔍 What I need to validate:
💡 How to improve the task context:
|
…s injected AiSdkAgentRunner.policyPrepareStep tried to compose the conversation with an `if (injectNote) ... else if (merged.messages)` chain, so when a policy injected a steering note at the same step that another policy produced a compressed window, the note branch rebuilt the message list from the uncompressed original (msgs ?? messages) and silently discarded the compression. The hard per-request context clamp from kodustech#1578 was bypassed. When both directives fire in one prepareStep the note is now appended to the compressed window (merged.messages mapped to model messages) instead of the raw conversation. Regression test drives CompressionPolicy + a note-injecting CompletionGatePolicy and asserts the model sees the steering note WITHOUT the full-size raw tool result (RED without the fix, GREEN with it).
fe5efe9 to
5c196d6
Compare
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
🤔 Insufficient Task ContextI found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details. 🔍 What I need to validate:
💡 How to improve the task context:
|
Fixes #1808
Problem
AiSdkAgentRunner.policyPrepareStepcomposed the conversation with anif (injectNote) ... else if (merged.messages)chain. When a policy injected a steering note (CompletionGatePolicy) at the same step that another policy produced a compressed window (CompressionPolicy), the note branch rebuilt the message list from the uncompressed original (msgs ?? messages) and discarded the compression — bypassing the hard per-request context clamp added for #1574 in #1578.Root cause
mergeDirectives()legitimately returns bothmessagesandinjectNote, but the note branch appended to the originalmsgs.Fix
When both fire, compute a single
baseMessages= the compressed window if present, else the original, and append the note to it:The note branch now spreads
baseMessages; the non-note branch uses it too.Validation
Regression test in
ai-sdk-agent-runner.compression.e2e.spec.tsdrivesCompressionPolicy(tiny window) + a note-injectingCompletionGatePolicytogether and asserts the model sees the steering note without the full-size raw tool result:readFileresult)No real model/network involved — mocked
ai/testmodel only.