Class AgentHealthIndicator
java.lang.Object
com.tnsai.quality.observability.health.AgentHealthIndicator
- All Implemented Interfaces:
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:
-
Field Summary
Fields inherited from interface com.tnsai.quality.observability.health.HealthIndicator
DEFAULT_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionAgentHealthIndicator(com.tnsai.agents.Agent agent) Creates an agent health indicator with default settings.AgentHealthIndicator(com.tnsai.agents.Agent agent, String name) Creates an agent health indicator with a custom name.AgentHealthIndicator(com.tnsai.agents.Agent agent, String name, double minSuccessRate) Creates an agent health indicator with custom settings. -
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.quality.observability.health.HealthIndicator
checkAsync, checkWithTimeout
-
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
Creates an agent health indicator with a custom name.- Parameters:
agent- the agent to monitorname- the indicator name (defaults to agent name)
-
AgentHealthIndicator
Creates an agent health indicator with custom settings.- Parameters:
agent- the agent to monitorname- the indicator name (null for default)minSuccessRate- minimum action success rate (0.0-1.0) for healthy status
-
-
Method Details
-
getName
Description copied from interface:HealthIndicatorGets the name of this health indicator.Default implementation returns the simple class name.
- Specified by:
getNamein interfaceHealthIndicator- Returns:
- the indicator name
-
check
Description copied from interface:HealthIndicatorPerforms 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:
checkin interfaceHealthIndicator- Returns:
- the health check result
-
getTimeout
Description copied from interface:HealthIndicatorGets the timeout for this health check.- Specified by:
getTimeoutin interfaceHealthIndicator- Returns:
- the timeout duration
-