Documentation
¶
Overview ¶
Package trajectory records and evaluates deterministic Agent execution facts. It keeps Agent vocabulary outside the subject-agnostic eval kernel and owns no experiment persistence, replay scheduler, or product workflow.
Index ¶
- Constants
- Variables
- type Config
- type Evaluator
- type Expectation
- type Limits
- type ModelCall
- type Recorder
- func (r *Recorder) OnEvent(_ context.Context, event agent.Event)
- func (r *Recorder) OnModelResponse(_ context.Context, invocation interaction.ModelInvocation, ...)
- func (r *Recorder) OnToolSettled(_ context.Context, invocation interaction.ToolInvocation, ...)
- func (r *Recorder) OnToolStarted(_ context.Context, invocation interaction.ToolInvocation)
- func (r *Recorder) Take(result agent.Result) (Trajectory, error)
- type Sample
- type ToolArguments
- type ToolCall
- type ToolExpectation
- type ToolOutcome
- type ToolSequence
- type Trajectory
- func (t Trajectory) BehaviorDigest() (string, error)
- func (t Trajectory) Clone() (Trajectory, error)
- func (t Trajectory) Duration() time.Duration
- func (t Trajectory) Events() []agent.Event
- func (t Trajectory) MarshalJSON() ([]byte, error)
- func (t Trajectory) ModelCalls() []ModelCall
- func (t Trajectory) Output() *agent.Output
- func (t Trajectory) RootProcessID() agent.ProcessID
- func (t Trajectory) Termination() agent.Termination
- func (t Trajectory) ToolCalls() []ToolCall
- func (t Trajectory) TotalTokens() (int64, error)
- func (t *Trajectory) UnmarshalJSON(data []byte) error
- func (t Trajectory) Usage() agent.Usage
- func (t Trajectory) Validate() error
Constants ¶
const ( MetricTrajectory eval.MetricName = "trajectory" MetricTaskSuccess eval.MetricName = "task_success" MetricToolCalls eval.MetricName = "tool_calls" MetricConsistency eval.MetricName = "consistency" MetricCommittedSteps eval.MetricName = "committed_steps" MetricPreparedEffects eval.MetricName = "prepared_effects" MetricAcceptedSignals eval.MetricName = "accepted_signals" MetricDroppedDeltas eval.MetricName = "dropped_deltas" MetricTotalTokens eval.MetricName = "total_tokens" MetricDuration eval.MetricName = "duration" )
Variables ¶
var ( ErrInvalidTrajectory = errors.New("eval/trajectory: invalid trajectory") ErrInvalidSample = errors.New("eval/trajectory: invalid sample") )
var ErrIncompleteRecording = errors.New("eval/trajectory: incomplete recording")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
RootProcessID agent.ProcessID
Termination agent.Termination
Output *agent.Output
Usage agent.Usage
Duration time.Duration
Events []agent.Event
ModelCalls []ModelCall
ToolCalls []ToolCall
}
Config supplies the complete facts owned by one Trajectory.
type Evaluator ¶
type Evaluator struct{}
Evaluator deterministically checks terminal success, exact Tool behavior, replay consistency, and configured resource regressions for one Sample. Its zero value is ready to use because all case-specific policy belongs to the typed Sample rather than mutable evaluator configuration.
type Expectation ¶
type Expectation struct {
Status agent.Status `json:"status"`
Output *agent.Output `json:"output,omitempty"`
Tools *ToolSequence `json:"tools,omitempty"`
Baseline *Trajectory `json:"baseline,omitempty"`
Limits Limits `json:"limits,omitzero"`
}
Expectation describes case-specific success without contaminating Metric identity. Baseline is optional and enables deterministic replay comparison.
func (Expectation) Validate ¶
func (e Expectation) Validate() error
type Limits ¶
type Limits struct {
CommittedSteps *uint64 `json:"committed_steps,omitempty"`
PreparedEffects *uint64 `json:"prepared_effects,omitempty"`
AcceptedSignals *uint64 `json:"accepted_signals,omitempty"`
DroppedDeltas *uint64 `json:"dropped_deltas,omitempty"`
TotalTokens *int64 `json:"total_tokens,omitempty"`
Duration *time.Duration `json:"duration,omitempty"`
}
Limits defines optional upper bounds. Pointers distinguish an asserted zero from a dimension the case does not evaluate.
type ModelCall ¶
type ModelCall struct {
ProcessID agent.ProcessID `json:"process_id"`
StepSequence uint64 `json:"step_sequence"`
CallSequence uint32 `json:"call_sequence"`
Response *chat.Response `json:"response"`
}
ModelCall is one settled model boundary attributed to an Agent Process Step.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder joins the Agent mechanics and Interaction semantic observation boundaries into owned Trajectories. Take consumes one completed root tree so a long-lived Engine does not turn evaluation capture into an unbounded log.
func (*Recorder) OnModelResponse ¶
func (r *Recorder) OnModelResponse( _ context.Context, invocation interaction.ModelInvocation, response *chat.Response, )
func (*Recorder) OnToolSettled ¶
func (r *Recorder) OnToolSettled( _ context.Context, invocation interaction.ToolInvocation, settlement interaction.ToolSettlement, )
func (*Recorder) OnToolStarted ¶
func (r *Recorder) OnToolStarted(_ context.Context, invocation interaction.ToolInvocation)
type Sample ¶
type Sample struct {
Actual Trajectory `json:"actual"`
Expected Expectation `json:"expected"`
}
Sample is the typed subject consumed by Evaluator.
type ToolArguments ¶
type ToolArguments string
ToolArguments is one exact semantic JSON argument assertion. Its empty value matches a Tool call that supplied no argument text.
func (ToolArguments) Validate ¶
func (t ToolArguments) Validate() error
type ToolCall ¶
type ToolCall struct {
ProcessID agent.ProcessID `json:"process_id"`
StepSequence uint64 `json:"step_sequence"`
ModelCall uint32 `json:"model_call"`
Index uint32 `json:"index"`
Call chat.ToolCall `json:"call"`
Outcome ToolOutcome `json:"outcome"`
Result *chat.ToolResult `json:"result,omitempty"`
Failure string `json:"failure,omitempty"`
}
ToolCall is one settled Tool boundary attributed to an Agent Process Step.
type ToolExpectation ¶
type ToolExpectation struct {
Name string `json:"name"`
Arguments *ToolArguments `json:"arguments,omitempty"`
Outcome ToolOutcome `json:"outcome,omitempty"`
}
func (ToolExpectation) Validate ¶
func (t ToolExpectation) Validate() error
type ToolOutcome ¶
type ToolOutcome string
ToolOutcome is the complete host-boundary outcome of one started Tool call.
const ( ToolOutcomeInvalid ToolOutcome = "" ToolOutcomeSucceeded ToolOutcome = "succeeded" ToolOutcomeError ToolOutcome = "error" ToolOutcomeInputRequired ToolOutcome = "input_required" ToolOutcomeFailed ToolOutcome = "failed" ToolOutcomeUnknown ToolOutcome = "unknown" )
func (ToolOutcome) Valid ¶
func (t ToolOutcome) Valid() bool
type ToolSequence ¶
type ToolSequence struct {
Calls []ToolExpectation `json:"calls"`
}
ToolSequence makes an exact ordered Tool-call assertion explicit. A nil *ToolSequence skips the assertion; a non-nil empty sequence asserts no calls.
type Trajectory ¶
type Trajectory struct {
// contains filtered or unexported fields
}
Trajectory is an owned, portable record of one completed root Process tree. Absolute timing and provider responses remain available in the record, but BehaviorDigest deliberately excludes them from replay comparison.
func New ¶
func New(config Config) (Trajectory, error)
func (Trajectory) BehaviorDigest ¶
func (t Trajectory) BehaviorDigest() (string, error)
BehaviorDigest identifies deterministic, semantic behavior while excluding wall-clock time, attempt duration, provider responses, and token usage.
func (Trajectory) Clone ¶
func (t Trajectory) Clone() (Trajectory, error)
func (Trajectory) Duration ¶
func (t Trajectory) Duration() time.Duration
func (Trajectory) Events ¶
func (t Trajectory) Events() []agent.Event
func (Trajectory) MarshalJSON ¶
func (t Trajectory) MarshalJSON() ([]byte, error)
func (Trajectory) ModelCalls ¶
func (t Trajectory) ModelCalls() []ModelCall
func (Trajectory) Output ¶
func (t Trajectory) Output() *agent.Output
func (Trajectory) RootProcessID ¶
func (t Trajectory) RootProcessID() agent.ProcessID
func (Trajectory) Termination ¶
func (t Trajectory) Termination() agent.Termination
func (Trajectory) ToolCalls ¶
func (t Trajectory) ToolCalls() []ToolCall
func (Trajectory) TotalTokens ¶
func (t Trajectory) TotalTokens() (int64, error)
func (*Trajectory) UnmarshalJSON ¶
func (t *Trajectory) UnmarshalJSON(data []byte) error
func (Trajectory) Usage ¶
func (t Trajectory) Usage() agent.Usage
func (Trajectory) Validate ¶
func (t Trajectory) Validate() error