fix(opencode): preserve tool context through compaction and prompt loops#21425
fix(opencode): preserve tool context through compaction and prompt loops#21425GuestAUser wants to merge 3 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found one potentially related PR: Related PR:
The current PR (#21425) appears to be the only PR addressing the specific combination of preserving tool context across compaction AND tool follow-ups. While there are other PRs related to compaction and tool handling (like #20289, #18764, #14393), none directly duplicate the functionality being added in PR #21425. No duplicate PRs found |
Memoize stable system prompt fragments across multi-step loop iterations so tool-call continuations stop rebuilding the same environment and skill text, while still reloading instruction files each step for correctness. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes #20246
Type of change
What does this PR do?
This PR fixes three related session-context problems in
packages/opencode/src/session.previous_response_idwhenstore: trueis explicitly enabled, so the continuation path sends the tool-result delta instead of replaying the full prompt history.SystemPrompt.skills(agent)andSystemPrompt.environment(model)while still reloadinginstruction.system()on every iteration so instruction changes remain visible on the next loop step.Together, these changes make multi-step sessions more context-preserving and more efficient without making instruction loading stale.
How did you verify your code works?
bun test test/session/message-v2.test.ts test/session/compaction.test.ts test/session/prompt-effect.test.ts test/session/processor-effect.test.tsbun typecheckAGENTS.mdinstructions are visible on the next iteration.SystemPrompt.skills()andSystemPrompt.environment()are only computed once across a two-iteration loop.Screenshots / recordings
N/A
Checklist