Package dev.dokimos.core.agents
Record Class AgentTrace
java.lang.Object
java.lang.Record
dev.dokimos.core.agents.AgentTrace
- Record Components:
finalResponse- the agent's final text responsetoolCalls- all tool calls made during executionreasoningSteps- optional reasoning/thought stepsmetadata- latency, token usage, and other metadata
public record AgentTrace(String finalResponse, List<ToolCall> toolCalls, List<String> reasoningSteps, Map<String,Object> metadata)
extends Record
Wraps a complete agent execution trace for evaluation.
Contains the agent's final text response, all tool calls made during execution, optional reasoning steps, and metadata such as latency and token usage.
The toOutputMap() method converts the trace to a map suitable for
returning from a Task implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing agent traces. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentTrace.Builderbuilder()Creates a new builder for constructing agent traces.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefinalResponserecord component.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.<T> TmetadataAs(String key, OutputType<T> type) Reads the metadata entry stored underkeyand converts it into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.<T> TmetadataAs(String key, Class<T> type) Reads the metadata entry stored underkeyand converts it into an instance oftype.Returns the value of thereasoningStepsrecord component.Returns the value of thetoolCallsrecord component.Returns the set of tool names used in this trace.Converts this agent trace to a map suitable for use asactualOutputsin anEvalTestCase.final StringtoString()Returns a string representation of this record class.toTestCase(String input) Builds anEvalTestCasefrom this trace for the given user input.toTestCase(String input, List<ToolDefinition> tools) Builds anEvalTestCasefrom this trace, also wiring the available tool definitions into metadata.toTestCase(String input, List<ToolDefinition> tools, List<String> tasks) Builds anEvalTestCasefrom this trace with everything the agent evaluators need in one call.
-
Constructor Details
-
AgentTrace
public AgentTrace(String finalResponse, List<ToolCall> toolCalls, List<String> reasoningSteps, Map<String, Object> metadata) Creates an instance of aAgentTracerecord class.- Parameters:
finalResponse- the value for thefinalResponserecord componenttoolCalls- the value for thetoolCallsrecord componentreasoningSteps- the value for thereasoningStepsrecord componentmetadata- the value for themetadatarecord component
-
-
Method Details
-
toOutputMap
Converts this agent trace to a map suitable for use asactualOutputsin anEvalTestCase.- Returns:
- a map with keys
"output","toolCalls", and"reasoningSteps"
-
toTestCase
Builds anEvalTestCasefrom this trace for the given user input.- Parameters:
input- the user input the agent responded to- Returns:
- a test case carrying this trace's outputs
- See Also:
-
toTestCase
Builds anEvalTestCasefrom this trace, also wiring the available tool definitions into metadata.- Parameters:
input- the user input the agent responded totools- the tool definitions available to the agent- Returns:
- a test case carrying this trace's outputs and tool definitions
- See Also:
-
toTestCase
Builds anEvalTestCasefrom this trace with everything the agent evaluators need in one call.This populates
output,toolCallsandreasoningStepsin actual outputs, andtoolsandtasksin metadata. It exists so callers stop hittingEvaluationExceptionwhen they forget to add thetoolsortasksentries thatToolCallValidityEvaluatorandTaskCompletionEvaluatorrequire.- Parameters:
input- the user input the agent responded to (may be null)tools- the tool definitions available to the agent (may be null)tasks- the tasks the agent was asked to complete (may be null)- Returns:
- a fully-populated test case
-
toolNames
Returns the set of tool names used in this trace.- Returns:
- set of tool names
-
metadataAs
Reads the metadata entry stored underkeyand converts it into an instance oftype.The value is already in memory, so this converts in place (no textual round-trip). An absent key (or a
nullstored value) yieldsnull.- Type Parameters:
T- the target type- Parameters:
key- the metadata keytype- the target class- Returns:
- the converted value, or
nullif the key is absent or its value isnull - Throws:
DokimosTypeConversionException- if the value cannot be converted totype
-
metadataAs
Reads the metadata entry stored underkeyand converts it into a generic target captured by anOutputTypetoken, for examplenew OutputType<List<String>>() {}.An absent key (or a
nullstored value) yieldsnull.- Type Parameters:
T- the target type- Parameters:
key- the metadata keytype- the captured generic output type- Returns:
- the converted value, or
nullif the key is absent or its value isnull - Throws:
DokimosTypeConversionException- if the value cannot be converted totype
-
builder
Creates a new builder for constructing agent traces.- Returns:
- a new builder
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
finalResponse
Returns the value of thefinalResponserecord component.- Returns:
- the value of the
finalResponserecord component
-
toolCalls
Returns the value of thetoolCallsrecord component.- Returns:
- the value of the
toolCallsrecord component
-
reasoningSteps
Returns the value of thereasoningStepsrecord component.- Returns:
- the value of the
reasoningStepsrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-