Skip to content

fix(tool): use call-scoped group activation#2333

Open
YingchaoX wants to merge 3 commits into
agentscope-ai:mainfrom
YingchaoX:fix/2169-tool-group-auth
Open

fix(tool): use call-scoped group activation#2333
YingchaoX wants to merge 3 commits into
agentscope-ai:mainfrom
YingchaoX:fix/2169-tool-group-auth

Conversation

@YingchaoX

Copy link
Copy Markdown

AgentScope-Java Version

2.0.1-SNAPSHOT

Description

Closes #2169.

Tool schemas exposed to the model are filtered using the active tool groups stored in the call-scoped ToolContextState. However, tool execution authorization previously checked the shared activation flags in ToolGroupManager.

When multiple sessions used different tool-group states, a tool could therefore be exposed to the model but rejected during execution with an Unauthorized tool call error.

This PR makes schema filtering and execution authorization use the same call-scoped state:

  • Adds a ToolGroupManager.isActiveTool overload that evaluates explicitly supplied active group names.
  • Resolves the current AgentState in ToolExecutor and authorizes grouped tools using ToolContextState.getActivatedGroups().
  • Preserves the existing shared-state behavior when no call-scoped agent state is available.
  • Adds focused regression tests covering:
    • A group active in call-scoped state but inactive in shared state.
    • A group inactive in call-scoped state but active in shared state.

Validation:

  • mvn spotless:apply
  • mvn test
  • git diff --check

No documentation changes are required because this fixes internal authorization-state consistency without changing the public API or documented usage.

Checklist

Please check the following items before code is ready to be reviewed.

  • 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 (not applicable; no documentation changes are required)
  • Code is ready for review

@CLAassistant

CLAassistant commented Jul 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...java/io/agentscope/core/tool/ToolGroupManager.java 87.50% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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.

[Bug]: 技能已经激活,但绑定的工具没有权限

2 participants