Package org.mockserver.llm.analysis
Class AgentRunAnalyzer
java.lang.Object
org.mockserver.llm.analysis.AgentRunAnalyzer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe correlated call graph of an agent run.static final classA directed edge in the agent-run call graph.static final classA node in the agent-run call graph.static final classStructural summary of an agent run (forexplain_agent_run).static final classA single tool call the assistant made.static final classResult of averify_tool_call-style inspection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildCallGraph(List<HttpRequest> requests, Provider provider) Build a correlated call graph for an agent run: a node per message, a node per assistant tool call,NEXTedges along the message sequence,INVOKESedges from an assistant turn to the tool calls it made, andRESULTedges from a tool call to the tool message that returned its result (correlated by tool-call id, mirroring the matcher's correlation).inspectToolCalls(List<HttpRequest> requests, Provider provider, String toolName, String argumentsRegex) Count the assistant tool calls matchingtoolName(and, optionally, whose arguments matchargumentsRegex) across the canonical conversation decoded from the given requests.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.
-
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 matchingtoolName(and, optionally, whose arguments matchargumentsRegex) 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
Build a correlated call graph for an agent run: a node per message, a node per assistant tool call,NEXTedges along the message sequence,INVOKESedges from an assistant turn to the tool calls it made, andRESULTedges 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.
-