-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Plan Mode Write Operations Denied When sessionId is Missing #21359
Copy link
Copy link
Labels
area/coreIssues related to User Interface, OS Support, Core FunctionalityIssues related to User Interface, OS Support, Core Functionalityarea/enterpriseIssues related to Telemetry, Policy, Quota / LicensingIssues related to Telemetry, Policy, Quota / Licensingworkstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreamsLabel used to tag epics and features that are associated with one of the three primary workstreams
Metadata
Metadata
Assignees
Labels
area/coreIssues related to User Interface, OS Support, Core FunctionalityIssues related to User Interface, OS Support, Core Functionalityarea/enterpriseIssues related to Telemetry, Policy, Quota / LicensingIssues related to Telemetry, Policy, Quota / Licensingworkstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreamsLabel used to tag epics and features that are associated with one of the three primary workstreams
Type
Fields
Give feedbackNo fields configured for Task.
Projects
Status
Closed
In Plan Mode, the
write_fileandreplacetools fail repeatedly when trying to save plans if thesessionIdis missing or undefined. This occurs because the security policy for Plan Mode enforces a strict directory structure that doesn't account for paths without a session-specific subdirectory.Reproduction Steps:
sessionIdis not provided to theStorageorConfigconstructor (e.g., during certain resumed sessions, subagent calls, or in testing environments).write_fileorreplace.Actual Behavior:
The tool execution is denied by the Policy Engine with the following message:
The agent fails to save the plan and often enters a loop of retrying the same failed operation.
Expected Behavior:
The agent should be able to save plans to the designated plans directory regardless of whether a
sessionIdsubdirectory is present, provided the path remains within the project's temporary directory.Technical Analysis:
The root cause is a discrepancy between how
Storagegenerates paths and how the security policy validates them:Strict Policy Regex: The
plan.tomlpolicy file uses a regular expression to allow writes to the plans directory:This regex requires exactly two subdirectories after
tmp/(representing both the<projectIdentifier>and the<sessionId>).Path Generation: When
sessionIdis missing,Storage.getProjectTempPlansDir()returns a path with only one subdirectory aftertmp/:~/.gemini/tmp/<projectIdentifier>/plans/Because this path only has one level of nesting instead of two, it fails the
argsPatterncheck. The request then falls through to the "Catch-All Deny" rule in the policy, leading to the failure.