Skip to content

Add tool governance advisors and reasoning trace observability#42

Open
vaquarkhan wants to merge 2 commits into
spring-ai-community:mainfrom
vaquarkhan:feature/tool-call-policy-advisor
Open

Add tool governance advisors and reasoning trace observability#42
vaquarkhan wants to merge 2 commits into
spring-ai-community:mainfrom
vaquarkhan:feature/tool-call-policy-advisor

Conversation

@vaquarkhan
Copy link
Copy Markdown

Summary

This PR adds a set of standalone ChatClient advisors for tool governance and loop observability in spring-ai-agent-utils:

  • ToolCallPolicyAdvisor for allow/deny/rewrite decisions before tool execution.
  • ToolApprovalAdvisor for human-in-the-loop approvals using CompletableFuture blocking.
  • ToolArgumentValidationAdvisor for tool argument byte-size limits.
  • ToolTimeoutAdvisor for per-tool timeout enforcement (with default + overrides).
  • ToolRateLimitAdvisor for per-request (loop) tool call rate limiting.
  • ToolFilterAdvisor for include/exclude filtering by glob-style tool name patterns.
  • ReasoningTraceAdvisor for per-iteration trace emission with timing and tool-call metadata.

Additional changes:

  • Added focused unit tests for all new advisors.
  • Added docs pages for each advisor under spring-ai-agent-utils/docs.
  • Updated spring-ai-agent-utils/README.md advisor section to include all new advisors.

Why

These advisors provide missing governance and observability controls commonly needed in production agent systems:

  • enforce policy and approval on tool usage,
  • bound unsafe/expensive tool calls (size, timeout, rate),
  • scope tool exposure by pattern,
  • improve loop-level traceability for operations and debugging.

Test Plan

  • Ran advisor-focused unit tests:
    • ToolCallPolicyAdvisorTest
    • ToolApprovalAdvisorTest
    • ToolArgumentValidationAdvisorTest
    • ToolTimeoutAdvisorTest
    • ToolRateLimitAdvisorTest
    • ToolFilterAdvisorTest
    • ReasoningTraceAdvisorTest
      -- Result: all tests passed (15 tests, 0 failures).

Command used:

mvn -f spring-ai-agent-utils/pom.xml "-Dtest=ToolCallPolicyAdvisorTest,ToolApprovalAdvisorTest,ToolArgumentValidationAdvisorTest,ToolTimeoutAdvisorTest,ToolRateLimitAdvisorTest,ToolFilterAdvisorTest,ReasoningTraceAdvisorTest" test

Introduce a standalone advisor that wraps tool callbacks and applies allow/deny/rewrite policy decisions before tool execution, with tests and documentation for integration.
Add ToolApprovalAdvisor, ToolArgumentValidationAdvisor, ToolTimeoutAdvisor, ToolRateLimitAdvisor, ToolFilterAdvisor, and ReasoningTraceAdvisor with tests and docs, and update README advisor listings.
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.

1 participant