Record Class AgentResult
- Record Components:
agentName- name of the sub-agent that produced this resultfindings- all findings from this agent's analysis passinputTokens- tokens consumed by the prompt sent to Claude APIoutputTokens- tokens consumed by Claude's responsedurationMs- wall-clock time for the API call in millisecondserrorMessage- non-null if the agent failed after max retries; null on successretryCount- number of retry attempts before success or failure (0 = first attempt succeeded)
Analogy: like a Future<T> result — the orchestrator submits
work to an agent and eventually receives this record back. It contains
not just the findings but also execution metadata (tokens used, time taken)
so the ContextWindowManager can track budget consumption across
all agents in the review session.
Flow: SubAgent.execute() → AgentResult →
OrchestratorAgent#escalate() (checks for CRITICAL, pauses if needed) →
AgentResultAggregator (merges into ReviewReport)
CERTIFICATION NOTE — Agentic Architecture & Orchestration (27% of exam):
AgentResult is the handoff object between the agentic loop stages.
Every stage in the orchestrator (COLLECT → EVALUATE → ESCALATE → AGGREGATE)
operates on this record. Understanding what travels between stages
is fundamental to designing multi-agent systems.
-
Constructor Summary
ConstructorsConstructorDescriptionAgentResult(String agentName, List<Finding> findings, int inputTokens, int outputTokens, long durationMs, String errorMessage, int retryCount) Creates an instance of aAgentResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theagentNamerecord component.longReturns the value of thedurationMsrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorMessagerecord component.static AgentResultReturns a failed result with a single ERROR finding.findings()Returns the value of thefindingsrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of theinputTokensrecord component.booleanReturns true if the agent completed without error.intReturns the value of theoutputTokensrecord component.intReturns the value of theretryCountrecord component.final StringtoString()Returns a string representation of this record class.intReturns total token usage for budget tracking.
-
Constructor Details
-
AgentResult
public AgentResult(String agentName, List<Finding> findings, int inputTokens, int outputTokens, long durationMs, String errorMessage, int retryCount) Creates an instance of aAgentResultrecord class.- Parameters:
agentName- the value for theagentNamerecord componentfindings- the value for thefindingsrecord componentinputTokens- the value for theinputTokensrecord componentoutputTokens- the value for theoutputTokensrecord componentdurationMs- the value for thedurationMsrecord componenterrorMessage- the value for theerrorMessagerecord componentretryCount- the value for theretryCountrecord component
-
-
Method Details
-
isSuccess
public boolean isSuccess()Returns true if the agent completed without error. -
totalTokens
public int totalTokens()Returns total token usage for budget tracking.CERTIFICATION NOTE — Domain 5: Context Management & Reliability (15%):
ContextWindowManagercalls this method after every agent completes to track cumulative token consumption across the entire review session. If the running total approaches the session budget, the manager splits remaining files into smaller batches before the next agent call. -
failed
Returns a failed result with a single ERROR finding.Used by
SubAgent.execute()after all retry attempts are exhausted. Returning a result (rather than throwing) lets the orchestrator continue with the remaining agents and include the failure in the final report. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
agentName
Returns the value of theagentNamerecord component.- Returns:
- the value of the
agentNamerecord component
-
findings
Returns the value of thefindingsrecord component.- Returns:
- the value of the
findingsrecord component
-
inputTokens
public int inputTokens()Returns the value of theinputTokensrecord component.- Returns:
- the value of the
inputTokensrecord component
-
outputTokens
public int outputTokens()Returns the value of theoutputTokensrecord component.- Returns:
- the value of the
outputTokensrecord component
-
durationMs
public long durationMs()Returns the value of thedurationMsrecord component.- Returns:
- the value of the
durationMsrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
retryCount
public int retryCount()Returns the value of theretryCountrecord component.- Returns:
- the value of the
retryCountrecord component
-