Record Class ValidationContext

java.lang.Object
java.lang.Record
com.tnsai.agents.validation.ValidationContext
Record Components:
llmClient - agent-level LLM, if any was set on the builder
roles - roles registered on the builder
hasExternalTools - true when at least one external tool (toolPojos / dynamicTools / builtInTools) is registered on the builder — the agent will expose tools to the LLM at chat time
memoryStore - agent-level memory store, if explicitly set on the builder (the InMemoryStore default applied by build() after validation is intentionally NOT surfaced here)
reachabilityTimeout - per-probe wall-clock budget for ReachabilityValidators; ignored by sync validators
hasConfirmationRequiredTool - true when at least one @Tool method on a registered tool POJO has requiresConfirmation = true (issue #234 — AGENT-V006)
toolCallFilterSet - true when the builder has a ToolCallFilter configured via AgentBuilder.toolCallFilter(...) (issue #234 — AGENT-V006)
tenantId - agent-level tenant identifier configured via AgentBuilder.tenantId(...); empty when no tenant scope is declared (issue #235 phase 1). AGENT-V012 (TenantScopeValidator) reads this field
mcpServerUrls - unique MCP server URLs collected from every MCP_TOOL action across all roles — consumed by MCPServerReachabilityValidator (AGENT-V011, issue #237). Empty set when no role declares any MCP-tool action

public record ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Optional<MemoryStore> memoryStore, Duration reachabilityTimeout, boolean hasConfirmationRequiredTool, boolean toolCallFilterSet, Optional<String> tenantId, Set<String> mcpServerUrls) extends Record
Read-only snapshot of an AgentBuilder state passed to each Validator. Keeps validators decoupled from AgentBuilder mutation surface — validators see a frozen view and cannot accidentally mutate or trigger side effects on the builder.

The tools list field was dropped in v0.6.0 — no remaining validator consumes it after the function-shape POJO migration. Tool uniqueness is now enforced by ToolMethodRegistry at registration time (see AgentBuilder.toolPojos). The lighter hasExternalTools boolean was reintroduced in 0.8.4 (issue #85 phase 1) so LLMCapabilityValidator can detect when the agent will pass tools to the LLM at runtime — without exposing the full POJO graph to validators that don't need it.

Since:
0.5.0 (issue #85); hasExternalTools since 0.8.4 (phase 1); reachabilityTimeout since 0.8.4 (phase 2a); memoryStore since 0.8.4 (phase 2b); hasConfirmationRequiredTool/toolCallFilterSet since 0.8.5 (issue #234); tenantId since 0.8.5 (issue #235 phase 1); mcpServerUrls since 0.8.6 (issue #237)
  • Field Details

    • DEFAULT_REACHABILITY_TIMEOUT

      public static final Duration DEFAULT_REACHABILITY_TIMEOUT
      Default per-probe timeout used when callers don't supply one.
  • Constructor Details

    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Optional<MemoryStore> memoryStore, Duration reachabilityTimeout, boolean hasConfirmationRequiredTool, boolean toolCallFilterSet, Optional<String> tenantId, Set<String> mcpServerUrls)
      Creates an instance of a ValidationContext record class.
      Parameters:
      llmClient - the value for the llmClient record component
      roles - the value for the roles record component
      hasExternalTools - the value for the hasExternalTools record component
      memoryStore - the value for the memoryStore record component
      reachabilityTimeout - the value for the reachabilityTimeout record component
      hasConfirmationRequiredTool - the value for the hasConfirmationRequiredTool record component
      toolCallFilterSet - the value for the toolCallFilterSet record component
      tenantId - the value for the tenantId record component
      mcpServerUrls - the value for the mcpServerUrls record component
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles)
      Backwards-compatible 2-arg constructor — defaults every later-added field to its safe / empty value so existing validator test fixtures keep compiling.
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools)
      3-arg constructor — defaults memoryStore, reachabilityTimeout, the V006 tool/filter flags, tenantId, and mcpServerUrls.
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Duration reachabilityTimeout)
      4-arg constructor — defaults memoryStore, the V006 tool/filter flags, tenantId, and mcpServerUrls.
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Optional<MemoryStore> memoryStore, Duration reachabilityTimeout)
      5-arg constructor (the pre-0.8.5 primary shape) — defaults the V006 tool/filter flags, tenantId, and mcpServerUrls so existing call sites keep compiling.
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Optional<MemoryStore> memoryStore, Duration reachabilityTimeout, boolean hasConfirmationRequiredTool, boolean toolCallFilterSet)
      7-arg constructor (the V006 shape) — defaults tenantId and mcpServerUrls so call sites added by issue #234 keep compiling.
    • ValidationContext

      public ValidationContext(Optional<LLMClient> llmClient, List<Role> roles, boolean hasExternalTools, Optional<MemoryStore> memoryStore, Duration reachabilityTimeout, boolean hasConfirmationRequiredTool, boolean toolCallFilterSet, Optional<String> tenantId)
      8-arg constructor (the V012 shape) — defaults mcpServerUrls so call sites added by issue #235 phase 2 keep compiling.
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • llmClient

      public Optional<LLMClient> llmClient()
      Returns the value of the llmClient record component.
      Returns:
      the value of the llmClient record component
    • roles

      public List<Role> roles()
      Returns the value of the roles record component.
      Returns:
      the value of the roles record component
    • hasExternalTools

      public boolean hasExternalTools()
      Returns the value of the hasExternalTools record component.
      Returns:
      the value of the hasExternalTools record component
    • memoryStore

      public Optional<MemoryStore> memoryStore()
      Returns the value of the memoryStore record component.
      Returns:
      the value of the memoryStore record component
    • reachabilityTimeout

      public Duration reachabilityTimeout()
      Returns the value of the reachabilityTimeout record component.
      Returns:
      the value of the reachabilityTimeout record component
    • hasConfirmationRequiredTool

      public boolean hasConfirmationRequiredTool()
      Returns the value of the hasConfirmationRequiredTool record component.
      Returns:
      the value of the hasConfirmationRequiredTool record component
    • toolCallFilterSet

      public boolean toolCallFilterSet()
      Returns the value of the toolCallFilterSet record component.
      Returns:
      the value of the toolCallFilterSet record component
    • tenantId

      public Optional<String> tenantId()
      Returns the value of the tenantId record component.
      Returns:
      the value of the tenantId record component
    • mcpServerUrls

      public Set<String> mcpServerUrls()
      Returns the value of the mcpServerUrls record component.
      Returns:
      the value of the mcpServerUrls record component