fix(harness): auto-inject ALLOW rules for plan mode tools#1960
Open
Buktal wants to merge 1 commit into
Open
Conversation
When HarnessAgent.Builder.enablePlanMode(true) is called, plan_enter, plan_write, and todo_write now get unconditional ALLOW rules injected into PermissionContextState so PermissionEngine does not prompt ASK under DEFAULT mode. plan_exit deliberately excluded to preserve HITL confirmation. Changes: - Add permissionContext mirror field in HarnessAgent.Builder - Modify permissionContext() setter to store locally instead of forwarding to inner immediately - In build(): merge user context + plan mode allow rules, then set inner.permissionContext() once - Add 6 tests verifying auto-injection behavior Fixes agentscope-ai#1910
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.0-SNAPSHOT
Description
Problem:
Issue #1910 reported that
PlanModeMiddlewarewhitelist andPermissionEnginewere not coordinated. WhenenablePlanMode(true)is called,plan_enter,plan_write, andtodo_writeare inPlanModeMiddleware.ALWAYS_ALLOWED(execution-layer whitelist), butPermissionEnginestill prompts ASK in DEFAULT mode because it has no awareness of plan mode context.Root Cause:
PlanModeMiddlewarecontrolsonActingphase (execution gate)PermissionEnginecontrolsonReasoningphase (permission prompt)Solution:
When
HarnessAgent.Builder.enablePlanMode(true)is called, automatically inject unconditional ALLOW rules forplan_enter,plan_write, andtodo_writeintoPermissionContextState.plan_exitis deliberately excluded to preserve HITL (Human-in-the-Loop) confirmation semantics.Changes:
permissionContextmirror field inHarnessAgent.Builder(default: empty context)permissionContext()setter to store locally instead of forwarding toinnerimmediatelybuild(): whenplanModeEnabled = true, merge user context + plan mode allow rules, then callinner.permissionContext()onceplanModeEnabled = false, directly forward user context toinner(behavior unchanged)Testing:
HarnessAgentPlanModePermissionTest:plan_enter/plan_write/todo_writeget ALLOW rules ✅plan_exithas no ALLOW rule (preserves ASK) ✅Backward Compatibility:
planModeEnabled = false(default): behavior unchangedFixes #1910
Checklist
mvn spotless:apply