fix(opencode): preserve readonly subagent restrictions across compaction#18764
fix(opencode): preserve readonly subagent restrictions across compaction#18764Haohao-end wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
I checked the Nix side locally and this looks unrelated to the changes in this PR. This PR only touches:
It does not touch The CI failure is Also, So this seems more like a pre-existing Nix/CI hash truncation issue in the evaluation path, rather than something caused by this PR. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #18213
Type of change
What does this PR do?
This fixes a case where readonly restrictions on plan-mode subagents could be lost after compaction.
The main issue was that when a child task session was created or resumed, the effective readonly
editrestriction from the parent context was not being persisted into the child session. On top of that, the legacytoolspath inSessionPrompt.prompt()could replace the existing session permission rules entirely, which removed inherited restrictions.This PR fixes that by:
editrestriction into child subagent sessions inTaskTool, including resumedtask_idsessionsSessionPrompt.prompt()to merge tool-derived permissions into the existing session rules instead of replacing the whole ruleseteditpermission for the shell write paths used in this issue (cat > .../ output redirection andsed -i), so those writes cannot bypass readonly mode after compactionI kept the shell-side change narrow to the repro path instead of expanding the general bash permission model.
How did you verify your code works?
I verified the change by:
task.ts,prompt.ts,compaction.ts,message-v2.ts, andbash.tsgit diff --checkpasseseditpermission for output redirectioneditpermission forsed -iI also verified this in CI after updating the branch: unit tests, e2e tests, typecheck, and nix-eval are now passing.
Screenshots / recordings
N/A
Checklist