Class AgentRunAnalyzer

java.lang.Object
org.mockserver.llm.analysis.AgentRunAnalyzer

public class AgentRunAnalyzer extends Object
Deterministic, read-only analysis of an agent run reconstructed from recorded LLM requests. Each request is decoded with the provider's ProviderCodec into a ParsedConversation; the richest conversation (most messages — i.e. the latest snapshot of the dialogue) is treated as the canonical run.

Pure (no network, no LLM): it inspects the structure the codecs already produce. Powers the verify_tool_call and explain_agent_run MCP tools.

  • Constructor Details

    • AgentRunAnalyzer

      public AgentRunAnalyzer()
  • Method Details

    • inspectToolCalls

      public AgentRunAnalyzer.ToolCallReport inspectToolCalls(List<HttpRequest> requests, Provider provider, String toolName, String argumentsRegex)
      Count the assistant tool calls matching toolName (and, optionally, whose arguments match argumentsRegex) across the canonical conversation decoded from the given requests.
      Parameters:
      argumentsRegex - optional regex matched (via find) against the tool call's argument JSON string; null/empty means any
    • summarise

      public Optional<AgentRunAnalyzer.RunSummary> summarise(List<HttpRequest> requests, Provider provider)
      Summarise the canonical conversation's structure: message and assistant turn counts, the ordered sequence of tool-call names, the tool names a result was returned for, and the latest message's role. Returns empty when no conversation can be decoded.
    • buildCallGraph

      public AgentRunAnalyzer.CallGraph buildCallGraph(List<HttpRequest> requests, Provider provider)
      Build a correlated call graph for an agent run: a node per message, a node per assistant tool call, NEXT edges along the message sequence, INVOKES edges from an assistant turn to the tool calls it made, and RESULT edges from a tool call to the tool message that returned its result (correlated by tool-call id, mirroring the matcher's correlation). Empty graph when nothing decodes.