Record Class AgentResult

java.lang.Object
java.lang.Record
ai.tabforge.workshop.model.AgentResult
Record Components:
agentName - name of the sub-agent that produced this result
findings - all findings from this agent's analysis pass
inputTokens - tokens consumed by the prompt sent to Claude API
outputTokens - tokens consumed by Claude's response
durationMs - wall-clock time for the API call in milliseconds
errorMessage - non-null if the agent failed after max retries; null on success
retryCount - number of retry attempts before success or failure (0 = first attempt succeeded)

public record AgentResult(String agentName, List<Finding> findings, int inputTokens, int outputTokens, long durationMs, String errorMessage, int retryCount) extends Record
What a sub-agent returns after executing its analysis pass.

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()AgentResultOrchestratorAgent#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 Details

    • AgentResult

      public AgentResult(String agentName, List<Finding> findings, int inputTokens, int outputTokens, long durationMs, String errorMessage, int retryCount)
      Creates an instance of a AgentResult record class.
      Parameters:
      agentName - the value for the agentName record component
      findings - the value for the findings record component
      inputTokens - the value for the inputTokens record component
      outputTokens - the value for the outputTokens record component
      durationMs - the value for the durationMs record component
      errorMessage - the value for the errorMessage record component
      retryCount - the value for the retryCount record 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%): ContextWindowManager calls 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

      public static AgentResult failed(String agentName, String errorMessage, int retryCount)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • agentName

      public String agentName()
      Returns the value of the agentName record component.
      Returns:
      the value of the agentName record component
    • findings

      public List<Finding> findings()
      Returns the value of the findings record component.
      Returns:
      the value of the findings record component
    • inputTokens

      public int inputTokens()
      Returns the value of the inputTokens record component.
      Returns:
      the value of the inputTokens record component
    • outputTokens

      public int outputTokens()
      Returns the value of the outputTokens record component.
      Returns:
      the value of the outputTokens record component
    • durationMs

      public long durationMs()
      Returns the value of the durationMs record component.
      Returns:
      the value of the durationMs record component
    • errorMessage

      public String errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • retryCount

      public int retryCount()
      Returns the value of the retryCount record component.
      Returns:
      the value of the retryCount record component