feat: permission-aware tool calling + progress display#3
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the REPL agent experience by (1) enforcing permission rules before tools execute inside Spring AI’s tool-calling loop, and (2) providing a simple progress indicator during blocking agent invocation.
Changes:
- Add an optional permission-check callback to
ToolCallbackAdapterand wire it fromAppConfigurationso deny rules can block tool execution. - Introduce
AgentInvoker.ToolProgressCallbackand register a REPL spinner callback inClaudeCodeJavaApplication. - Add a new unit test verifying allow/deny/fail-open behavior for the adapter’s permission checker.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ccc-tools/src/main/java/com/ccj/tools/adapter/ToolCallbackAdapter.java | Adds optional permission-check hook before delegating to tool.call(...). |
| ccc-test/src/test/java/com/ccj/test/PermissionAwareAdapterTest.java | Adds tests covering permission-check allow/deny and checker exception behavior. |
| ccc-app/src/main/java/com/ccj/app/invoker/AgentInvoker.java | Adds tool progress callback wiring around the blocking .call() path. |
| ccc-app/src/main/java/com/ccj/app/ClaudeCodeJavaApplication.java | Registers a terminal spinner callback for agent processing. |
| ccc-app/src/main/java/com/ccj/app/AppConfiguration.java | Wires PermissionCheckerImpl into tool callbacks (permission-aware tool execution). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
11
to
+12
| import java.util.Optional; | ||
| import java.util.function.Consumer; |
Comment on lines
+99
to
+108
| com.ccj.core.tool.PermissionResult result = permissionChecker.check(tool, input, ctx); | ||
| if (result instanceof com.ccj.core.tool.PermissionResult.Deny d) { | ||
| return d.message(); | ||
| } | ||
| // Allow 和 Ask 都放行(Ask 在 REPL 层处理,此处简化为允许) | ||
| return null; | ||
| } catch (Exception e) { | ||
| log.warn("Permission check failed for {}: {}", tool.name(), e.getMessage()); | ||
| return null; // 出错时允许(fail-open) | ||
| } |
Comment on lines
+38
to
+40
| /** 权限检查器接口(可选)。设置后在每次工具调用前检查权限。 */ | ||
| @FunctionalInterface | ||
| public interface PermissionChecker { |
Comment on lines
+52
to
56
| public ToolCallbackAdapter(Tool tool, ToolUseContext contextTemplate, PermissionChecker permissionChecker) { | ||
| this.tool = tool; | ||
| this.contextTemplate = contextTemplate; | ||
| this.permissionChecker = permissionChecker; | ||
| } |
| } | ||
| } catch (Exception e) { | ||
| // 权限检查器异常:fail-open(记录但不阻断) | ||
| log.warn("Permission checker exception for {}: {}", tool.name(), e.getMessage()); |
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.
Summary
Adds two features that make the agent more usable:
1. Permission-aware tool calling
2. Tool execution progress display
Test Results
Note on streaming
Spring AI 2.0.0's ToolCallAdvisor.adviseStream is unimplemented (throws UnsupportedOperationException). True token-by-token streaming would require either removing ToolCallAdvisor (losing advisor-level tool interception) or implementing a custom streaming-capable advisor. For now, the progress spinner provides user feedback during the blocking .call() path which correctly handles the tool-calling loop.