Report an unsaved trajectory somewhere that survives
A failed save must not fail the run -- the answer already exists -- but until now the only record of the loss was an error entry appended to the trajectory that had just failed to save. §6 says the trajectory is not optional telemetry; losing one silently is the worst version of losing one. The runtime has no logger by design, so ExecutionResult gains an Unsaved list the surface reads and turns into a §10 log line with run_id, tenant_id, agent_key and agent_version. Never serialised to the client. Covered on all three run paths, streaming included. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJvibeSc1JYXjatankqM1g
This commit is contained in:
@@ -265,6 +265,28 @@ func TestSinkFailureDoesNotFailTheRun(t *testing.T) {
|
||||
if res.Output != "the answer" {
|
||||
t.Errorf("Output = %q, want the answer through", res.Output)
|
||||
}
|
||||
// ...but the loss must be reported somewhere that survives. The runtime
|
||||
// has no logger; the surface reads this and writes the operator's line.
|
||||
// Before this field existed the only record was an entry in the very
|
||||
// trajectory that had failed to save.
|
||||
if len(res.Unsaved) != 1 || !strings.Contains(res.Unsaved[0], res.RunID) ||
|
||||
!strings.Contains(res.Unsaved[0], context.DeadlineExceeded.Error()) {
|
||||
t.Errorf("Unsaved = %v, want one entry naming run %s and the error", res.Unsaved, res.RunID)
|
||||
}
|
||||
}
|
||||
|
||||
// A healthy run reports nothing unsaved. Guarded so the surface never logs a
|
||||
// phantom loss.
|
||||
func TestHealthySaveReportsNothingUnsaved(t *testing.T) {
|
||||
gw := &fakeGateway{text: "the answer"}
|
||||
exec := NewModelExecutor(gw, &MemorySink{}, nil)
|
||||
res, err := exec.ExecuteAgent(context.Background(), testAgent(), testInput("q"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(res.Unsaved) != 0 {
|
||||
t.Errorf("Unsaved = %v on a healthy run, want none", res.Unsaved)
|
||||
}
|
||||
}
|
||||
|
||||
type failingSink struct{}
|
||||
|
||||
Reference in New Issue
Block a user