Repository navigation
fix(run): apply the non-interactive deny rules to resumed sessions - #44559
gitRasheed wants to merge 2 commits into
Conversation
20a3c3f to
5932b99
Compare
The deny rules for question, plan_enter and plan_exit were applied only when run created the session itself. The --session, --continue and --fork paths returned without them, so a session created elsewhere resumed with the question tool live, and an asked question blocked the run forever with no server-side timeout: --auto answers only permission.asked and question.asked has no handler. Resumed and forked sessions now receive the same rules before prompting. The update is skipped when the ruleset already ends with exactly these rules, so repeated resumes do not grow it, and a failed read or update aborts the run instead of proceeding without the rules. Interactive resumes are unchanged.
5932b99 to
932f644
Compare
Overall: real bug, right fix — resuming an externally created session without re-applying the non-interactive denies leaves
Minor: sessions resumed across CLI versions with changed rule sets will accumulate stale deny tails (acknowledged in the comment as harmless — agree, since last-wins ordering makes them inert). The duplicated-rule scenario might deserve a tiny assertion in the second test so future refactors of the tail check don't silently regress idempotence. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #44556
Type of change
What does this PR do?
Headless
opencode runadds deny rules forquestion,plan_enterandplan_exitonly when creating a session. The--session,--continueand--forkpaths return first, so sessions created elsewhere, including over HTTP, can resume with the question tool enabled. A question then blocks on a Deferred with no server-side timeout.--autoonly handlespermission.asked, while questions use the unhandledquestion.askedchannel.This applies the same rules to resumed and forked sessions before prompting via
session.update; the server merges rulesets and the evaluator takes the last match, so the appended rules win. The update is skipped when the ruleset already ends with these rules, and a failed read or update aborts the run. Interactive resumes are unchanged.How did you verify your code works?
Two subprocess tests in
test/cli/run/permission-resume.test.tsresume an HTTP-created session: one asserts the deny rules land last, the other has the model call the question tool and asserts the run completes. Both fail unpatched; suite and typecheck pass.Screenshots / recordings
Not a UI change.
Checklist