Skip to content

feat(harness): expose replacePermissionContext on HarnessAgent - #4117

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-4108-harness-replace-permission-context
Nov 11, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-4108-harness-replace-permission-context

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (main)

Description

Fixes #4108

HarnessAgent forwards setPermissionMode(...) and getPermissionMode(...) to the wrapped ReActAgent, but not replacePermissionContext(...). A shared HarnessAgent that serves several users can therefore switch the mode per session, but has to go through getDelegate() to install per-session allow/deny/ask rules.

Changes:

  • Add HarnessAgent.replacePermissionContext(userId, sessionId, permissionContext), forwarding to ReActAgent#replacePermissionContext.
  • Add a test that replaces the context for one (userId, sessionId) and checks that another user's session is not affected.
  • Document the method in the runtime permission switching section of plan-mode.md (EN and ZH).

Not included: the getAgentState(RuntimeContext) / getAgentState(String, String) overloads mentioned in the issue. The deprecated HarnessAgent.getAgentState() already points to getDelegate() for those, so I left that as is.

How to test:

  • mvn -T1C -pl agentscope-harness -am test -Dtest=HarnessAgentTest -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B -T1C -pl agentscope-harness -am verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true passes locally.
  • node scripts/check-docs.mjs and node --test scripts/tests/*.test.mjs pass in docs/. mint validate / mint broken-links were not run locally.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

HarnessAgent forwarded setPermissionMode/getPermissionMode to the wrapped
ReActAgent but not replacePermissionContext, so a shared agent could not
install per-session permission rules without going through getDelegate().

Fixes agentscope-ai#4108
@mintlify

mintlify Bot commented Nov 11, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 7c7eabc.

Approve preview

@jujn
jujn merged commit f45820e into agentscope-ai:main Nov 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HarnessAgent 未转发 getAgentState(RuntimeContext) / replacePermissionContext,多用户场景无法设置工具权限

3 participants