Class AgentHealthIndicator

java.lang.Object
com.tnsai.quality.observability.health.AgentHealthIndicator
All Implemented Interfaces:
HealthIndicator

public class AgentHealthIndicator extends Object implements HealthIndicator
Health indicator for TnsAI agents.

Checks agent health by verifying:

  • Agent is not null and has valid configuration
  • Agent's LLM client is available (if applicable)
  • Recent action success rate (if metrics available)
  • Memory store accessibility

Example usage:


 Agent myAgent = Agent.builder()
     .name("MyAgent")
     .llmClient(client)
     .build();

 HealthRegistry.getInstance()
     .register(new AgentHealthIndicator(myAgent));

 // Or register with custom name
 HealthRegistry.getInstance()
     .register("my-agent", new AgentHealthIndicator(myAgent));
 
See Also:
  • Constructor Details

    • AgentHealthIndicator

      public AgentHealthIndicator(com.tnsai.agents.Agent agent)
      Creates an agent health indicator with default settings.
      Parameters:
      agent - the agent to monitor
    • AgentHealthIndicator

      public AgentHealthIndicator(com.tnsai.agents.Agent agent, String name)
      Creates an agent health indicator with a custom name.
      Parameters:
      agent - the agent to monitor
      name - the indicator name (defaults to agent name)
    • AgentHealthIndicator

      public AgentHealthIndicator(com.tnsai.agents.Agent agent, String name, double minSuccessRate)
      Creates an agent health indicator with custom settings.
      Parameters:
      agent - the agent to monitor
      name - the indicator name (null for default)
      minSuccessRate - minimum action success rate (0.0-1.0) for healthy status
  • Method Details

    • getName

      public String getName()
      Description copied from interface: HealthIndicator
      Gets the name of this health indicator.

      Default implementation returns the simple class name.

      Specified by:
      getName in interface HealthIndicator
      Returns:
      the indicator name
    • check

      public HealthCheckResult check()
      Description copied from interface: HealthIndicator
      Performs the health check and returns the result.

      Implementations should:

      • Return quickly (under 10 seconds)
      • Not throw exceptions (return DOWN status instead)
      • Include relevant details in the result
      Specified by:
      check in interface HealthIndicator
      Returns:
      the health check result
    • getTimeout

      public Duration getTimeout()
      Description copied from interface: HealthIndicator
      Gets the timeout for this health check.
      Specified by:
      getTimeout in interface HealthIndicator
      Returns:
      the timeout duration