Class ToolApprovalValidator

java.lang.Object
com.tnsai.agents.validation.validators.ToolApprovalValidator
All Implemented Interfaces:
Validator

public final class ToolApprovalValidator extends Object implements Validator
AGENT-V006 — at least one registered tool declares @Tool(requiresConfirmation = true) but the agent has no ToolCallFilter configured to gate the call.

Without a filter, the runtime executes confirmation-gated tools unattended, defeating the safety contract the @Tool annotation advertises. Issue #234 spun this validator off from issue #85's original spec because the underlying primitives didn't exist yet — both ship together in 0.8.5.

Severity

Emitted as Severity.WARNING, matching the soft-launch convention shared by V002, V003, V005, V010 — the missing filter may be intentional (e.g. trusted environment, post-build wiring through a different code path), and a warning gives consumers a release cycle to either install a filter or suppress with .relaxValidation("AGENT-V006").

Conservative skip rules

  • No tool declares requiresConfirmation = true → silent (signal precomputed by the builder via reflection; reflection failures are treated as "no signal", not "definitely safe").
  • A ToolCallFilter is wired through AgentBuilder.toolCallFilter(...) → silent. The validator does not inspect the filter's policy — declaring any filter at all is treated as opt-in to the runtime approval contract.

Why this is build-time rather than runtime-discovered

The framework already raises a runtime exception when a confirmation-gated tool fires without a filter, but only on the first dispatch — typically minutes or hours into production. Surfacing the gap at build time follows the same "fail at the configuration site, not at the call site" principle as the other validators.

Since:
0.8.5 (issue #234)
  • Constructor Details

    • ToolApprovalValidator

      public ToolApprovalValidator()
  • Method Details

    • id

      public String id()
      Description copied from interface: Validator
      Short, stable id for logging and test assertions (e.g. "llm-presence").
      Specified by:
      id in interface Validator
    • validate

      public List<ValidationIssue> validate(ValidationContext ctx)
      Description copied from interface: Validator
      Inspect the agent configuration and return any issues detected. Returning an empty list means "no problems found by this validator".
      Specified by:
      validate in interface Validator
      Parameters:
      ctx - frozen view of the agent under construction
      Returns:
      zero-or-more issues; never null