Retain native prompt execution evidence
This commit is contained in:
@@ -318,6 +318,12 @@ group behavior rather than retesting its aggregation algebra or provider
|
|||||||
decoders. Ordinary-report counts and role progress still function without
|
decoders. Ordinary-report counts and role progress still function without
|
||||||
debug capture.
|
debug capture.
|
||||||
|
|
||||||
|
**Complete.** The collector retains native PromptKit events and group summaries
|
||||||
|
alongside Audita's logical-call attribution. Focused LLM tests pass for
|
||||||
|
concurrent attribution, snapshot ownership, coverage, reasoning and cache
|
||||||
|
usage, cost, and replayed group evidence. The debug serializer and its tests
|
||||||
|
still consume the former projection and are migrated in the next stage.
|
||||||
|
|
||||||
## Stage 6: Serialize the Native Diagnostic Envelope
|
## Stage 6: Serialize the Native Diagnostic Envelope
|
||||||
|
|
||||||
**Outcome:** One debug format exposes native evidence with Audita's stage,
|
**Outcome:** One debug format exposes native evidence with Audita's stage,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func TestCoordinatorFinalTurnFailuresAndAccounting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
snapshot := collector.Snapshot()
|
snapshot := collector.Snapshot()
|
||||||
summary := Summarize(snapshot)
|
summary := Summarize(snapshot)
|
||||||
if len(snapshot.Calls) != 2 || summary.ProviderAttempts != 2 || !summary.TerminalCoverageComplete {
|
if len(snapshot.Calls) != 2 || summary.PromptKit.Attempts != 2 || !summary.PromptKit.TerminalCoverageComplete {
|
||||||
t.Fatalf("summary=%+v calls=%+v", summary, snapshot.Calls)
|
t.Fatalf("summary=%+v calls=%+v", summary, snapshot.Calls)
|
||||||
}
|
}
|
||||||
for _, call := range snapshot.Calls {
|
for _, call := range snapshot.Calls {
|
||||||
@@ -106,7 +106,7 @@ func TestCoordinatorCanceledDeliveryRetainsEvidence(t *testing.T) {
|
|||||||
if !errors.Is(err, context.Canceled) || deliveries != 1 {
|
if !errors.Is(err, context.Canceled) || deliveries != 1 {
|
||||||
t.Fatalf("deliveries=%d err=%v", deliveries, err)
|
t.Fatalf("deliveries=%d err=%v", deliveries, err)
|
||||||
}
|
}
|
||||||
if got := Summarize(collector.Snapshot()); got.ProviderAttempts != 2 || !got.TerminalCoverageComplete {
|
if got := Summarize(collector.Snapshot()); got.PromptKit.Attempts != 2 || !got.PromptKit.TerminalCoverageComplete {
|
||||||
t.Fatalf("summary=%+v", got)
|
t.Fatalf("summary=%+v", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ func TestCoordinatorReleasesAdmissionBeforeNestedValidation(t *testing.T) {
|
|||||||
return &structuredoutput.Request{PromptID: prompts.PromptIDModuleGrammarRepair, CaptureDiagnostics: true, Variables: map[string]string{"RepairRequestJSON": "{}"}}, nil
|
return &structuredoutput.Request{PromptID: prompts.PromptIDModuleGrammarRepair, CaptureDiagnostics: true, Variables: map[string]string{"RepairRequestJSON": "{}"}}, nil
|
||||||
})
|
})
|
||||||
summary := Summarize(collector.Snapshot())
|
summary := Summarize(collector.Snapshot())
|
||||||
if err != nil || count.Load() != 3 || summary.ProviderAttempts != 3 || summary.LogicalCalls != 3 || !summary.TerminalCoverageComplete {
|
if err != nil || count.Load() != 3 || summary.PromptKit.Attempts != 3 || summary.LogicalCalls != 3 || !summary.PromptKit.TerminalCoverageComplete {
|
||||||
t.Fatalf("calls=%d summary=%+v err=%v", count.Load(), summary, err)
|
t.Fatalf("calls=%d summary=%+v err=%v", count.Load(), summary, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,47 +9,11 @@ import (
|
|||||||
pk "go.maximumdirect.net/promptkit"
|
pk "go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TokenCount retains the distinction between zero and unavailable usage.
|
// ExecutionObservation combines an Audita logical call with native execution evidence.
|
||||||
type TokenCount struct {
|
|
||||||
Value int `json:"value"`
|
|
||||||
Known bool `json:"known"`
|
|
||||||
Complete bool `json:"complete"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Usage struct {
|
|
||||||
Prompt TokenCount `json:"prompt"`
|
|
||||||
Completion TokenCount `json:"completion"`
|
|
||||||
Total TokenCount `json:"total"`
|
|
||||||
Cached TokenCount `json:"cached"`
|
|
||||||
CacheWrite TokenCount `json:"cache_write"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExecutionObservation contains execution metadata only. It never contains
|
|
||||||
// endpoint URLs, credentials, messages, provider errors, or generated text.
|
|
||||||
type ExecutionObservation struct {
|
type ExecutionObservation struct {
|
||||||
CallID uint64 `json:"call_id"`
|
CallID uint64 `json:"call_id"`
|
||||||
Context structuredoutput.DiagnosticContext `json:"context"`
|
Context structuredoutput.DiagnosticContext `json:"context"`
|
||||||
Kind string `json:"kind"`
|
PromptKit pk.ExecutionEvent `json:"promptkit"`
|
||||||
RunID string `json:"run_id,omitempty"`
|
|
||||||
Time time.Time `json:"time"`
|
|
||||||
BackendID string `json:"backend_id,omitempty"`
|
|
||||||
ProfileID string `json:"profile_id,omitempty"`
|
|
||||||
Model string `json:"model,omitempty"`
|
|
||||||
Generation uint64 `json:"generation,omitempty"`
|
|
||||||
Attempt uint64 `json:"attempt,omitempty"`
|
|
||||||
Dispatched bool `json:"dispatched"`
|
|
||||||
CapacityWait time.Duration `json:"capacity_wait_ns"`
|
|
||||||
GenerationDuration time.Duration `json:"generation_duration_ns"`
|
|
||||||
RetryDelay time.Duration `json:"retry_delay_ns"`
|
|
||||||
Duration time.Duration `json:"duration_ns"`
|
|
||||||
Outcome string `json:"outcome,omitempty"`
|
|
||||||
Failure string `json:"failure,omitempty"`
|
|
||||||
StatusCode int `json:"status_code,omitempty"`
|
|
||||||
RetriesExhausted bool `json:"retries_exhausted,omitempty"`
|
|
||||||
Attempts uint64 `json:"attempts"`
|
|
||||||
TransientRetries uint64 `json:"transient_retries"`
|
|
||||||
StructuralRepairs uint64 `json:"structural_repairs"`
|
|
||||||
Usage Usage `json:"usage"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogicalCall struct {
|
type LogicalCall struct {
|
||||||
@@ -70,12 +34,8 @@ type ObservationSnapshot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ExecutionSummary struct {
|
type ExecutionSummary struct {
|
||||||
TerminalCoverageComplete bool `json:"terminal_coverage_complete"`
|
LogicalCalls uint64 `json:"logical_calls"`
|
||||||
LogicalCalls uint64 `json:"logical_calls"`
|
PromptKit pk.ExecutionGroupSummary `json:"promptkit"`
|
||||||
ProviderAttempts uint64 `json:"provider_attempts"`
|
|
||||||
TransientRetries uint64 `json:"transient_retries"`
|
|
||||||
StructuralRepairs uint64 `json:"structural_repairs"`
|
|
||||||
Usage Usage `json:"usage"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObservationCollector accepts short synchronous callbacks from parallel calls.
|
// ObservationCollector accepts short synchronous callbacks from parallel calls.
|
||||||
@@ -140,22 +100,10 @@ func (c *ObservationCollector) recordEvent(callID uint64, context structuredoutp
|
|||||||
if c == nil {
|
if c == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.group.Observe(event)
|
|
||||||
count := func(value pk.ObservedTokenCount) TokenCount {
|
|
||||||
return TokenCount{Value: value.Value, Known: value.Known, Complete: value.Complete}
|
|
||||||
}
|
|
||||||
observation := ExecutionObservation{
|
|
||||||
CallID: callID, Context: copyContext(context), Kind: string(event.Kind), RunID: event.RunID,
|
|
||||||
Time: event.Time, BackendID: event.BackendID, ProfileID: event.ProfileID, Model: event.Model,
|
|
||||||
Generation: event.Generation, Attempt: event.Attempt, Dispatched: event.Dispatched,
|
|
||||||
CapacityWait: event.CapacityWait, GenerationDuration: event.GenerationDuration, RetryDelay: event.RetryDelay, Duration: event.Duration,
|
|
||||||
Outcome: string(event.Outcome), Failure: string(event.Failure), StatusCode: event.StatusCode, RetriesExhausted: event.RetriesExhausted,
|
|
||||||
Attempts: event.Attempts, TransientRetries: event.TransientRetries, StructuralRepairs: event.RepairCalls,
|
|
||||||
Usage: Usage{Prompt: count(event.Usage.PromptTokens), Completion: count(event.Usage.CompletionTokens), Total: count(event.Usage.TotalTokens), Cached: count(event.Usage.CachedTokens), CacheWrite: count(event.Usage.CacheWriteTokens)},
|
|
||||||
}
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.events = append(c.events, observation)
|
defer c.mu.Unlock()
|
||||||
c.mu.Unlock()
|
c.group.Observe(event)
|
||||||
|
c.events = append(c.events, ExecutionObservation{CallID: callID, Context: copyContext(context), PromptKit: event})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ObservationCollector) Snapshot() ObservationSnapshot {
|
func (c *ObservationCollector) Snapshot() ObservationSnapshot {
|
||||||
@@ -178,7 +126,7 @@ func (c *ObservationCollector) Snapshot() ObservationSnapshot {
|
|||||||
if snapshot.Events[i].CallID != snapshot.Events[j].CallID {
|
if snapshot.Events[i].CallID != snapshot.Events[j].CallID {
|
||||||
return snapshot.Events[i].CallID < snapshot.Events[j].CallID
|
return snapshot.Events[i].CallID < snapshot.Events[j].CallID
|
||||||
}
|
}
|
||||||
return snapshot.Events[i].Time.Before(snapshot.Events[j].Time)
|
return snapshot.Events[i].PromptKit.Time.Before(snapshot.Events[j].PromptKit.Time)
|
||||||
})
|
})
|
||||||
group := c.group.Snapshot()
|
group := c.group.Snapshot()
|
||||||
snapshot.Group = &group
|
snapshot.Group = &group
|
||||||
@@ -188,20 +136,14 @@ func (c *ObservationCollector) Snapshot() ObservationSnapshot {
|
|||||||
// Summarize delegates deduplication and terminal accounting to PromptKit. A
|
// Summarize delegates deduplication and terminal accounting to PromptKit. A
|
||||||
// filtered diagnostic view selects its own group; overlapping views are not additive.
|
// filtered diagnostic view selects its own group; overlapping views are not additive.
|
||||||
func Summarize(snapshot ObservationSnapshot) ExecutionSummary {
|
func Summarize(snapshot ObservationSnapshot) ExecutionSummary {
|
||||||
summary := snapshot.Group
|
if snapshot.Group != nil {
|
||||||
if summary == nil {
|
group := *snapshot.Group
|
||||||
var group pk.ExecutionGroup
|
group.Members = append([]pk.ExecutionGroupMember(nil), group.Members...)
|
||||||
count := func(c TokenCount) pk.ObservedTokenCount {
|
return ExecutionSummary{LogicalCalls: uint64(len(snapshot.Calls)), PromptKit: group}
|
||||||
return pk.ObservedTokenCount{Value: c.Value, Known: c.Known, Complete: c.Complete}
|
|
||||||
}
|
|
||||||
for _, event := range snapshot.Events {
|
|
||||||
group.Observe(pk.ExecutionEvent{Kind: pk.ExecutionEventKind(event.Kind), RunID: event.RunID, Attempts: event.Attempts, TransientRetries: event.TransientRetries, RepairCalls: event.StructuralRepairs, Usage: pk.ObservedTokenUsage{PromptTokens: count(event.Usage.Prompt), CompletionTokens: count(event.Usage.Completion), TotalTokens: count(event.Usage.Total), CachedTokens: count(event.Usage.Cached), CacheWriteTokens: count(event.Usage.CacheWrite)}})
|
|
||||||
}
|
|
||||||
value := group.Snapshot()
|
|
||||||
summary = &value
|
|
||||||
}
|
}
|
||||||
count := func(c pk.ObservedTokenCount) TokenCount {
|
var group pk.ExecutionGroup
|
||||||
return TokenCount{Value: c.Value, Known: c.Known, Complete: c.Complete}
|
for _, event := range snapshot.Events {
|
||||||
|
group.Observe(event.PromptKit)
|
||||||
}
|
}
|
||||||
return ExecutionSummary{LogicalCalls: uint64(len(snapshot.Calls)), TerminalCoverageComplete: summary.TerminalCoverageComplete, ProviderAttempts: summary.Attempts, TransientRetries: summary.TransientRetries, StructuralRepairs: summary.RepairCalls, Usage: Usage{Prompt: count(summary.Usage.PromptTokens), Completion: count(summary.Usage.CompletionTokens), Total: count(summary.Usage.TotalTokens), Cached: count(summary.Usage.CachedTokens), CacheWrite: count(summary.Usage.CacheWriteTokens)}}
|
return ExecutionSummary{LogicalCalls: uint64(len(snapshot.Calls)), PromptKit: group.Snapshot()}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func TestObservationSummarySeparatesLogicalCallsAttemptsAndUsage(t *testing.T) {
|
|||||||
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{Role: "proposal"}, pk.ExecutionEvent{RunID: "run-2", Kind: pk.ExecutionAttempt, Dispatched: false})
|
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{Role: "proposal"}, pk.ExecutionEvent{RunID: "run-2", Kind: pk.ExecutionAttempt, Dispatched: false})
|
||||||
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{Role: "proposal"}, pk.ExecutionEvent{RunID: "run-2", Kind: pk.ExecutionFinished, Attempts: 0, Usage: pk.ObservedTokenUsage{PromptTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CompletionTokens: pk.ObservedTokenCount{Known: true, Complete: true}, TotalTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CachedTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CacheWriteTokens: pk.ObservedTokenCount{Known: true, Complete: true}}})
|
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{Role: "proposal"}, pk.ExecutionEvent{RunID: "run-2", Kind: pk.ExecutionFinished, Attempts: 0, Usage: pk.ObservedTokenUsage{PromptTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CompletionTokens: pk.ObservedTokenCount{Known: true, Complete: true}, TotalTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CachedTokens: pk.ObservedTokenCount{Known: true, Complete: true}, CacheWriteTokens: pk.ObservedTokenCount{Known: true, Complete: true}}})
|
||||||
summary := Summarize(collector.Snapshot())
|
summary := Summarize(collector.Snapshot())
|
||||||
if summary.LogicalCalls != 2 || summary.ProviderAttempts != 0 || summary.Usage.Total != (TokenCount{Known: true, Complete: true}) {
|
if summary.LogicalCalls != 2 || summary.PromptKit.Attempts != 0 || summary.PromptKit.Usage.TotalTokens != (pk.ObservedTokenCount{Known: true, Complete: true}) {
|
||||||
t.Fatalf("zero-attempt accounting: %+v", summary)
|
t.Fatalf("zero-attempt accounting: %+v", summary)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ func TestObservationSummarySeparatesLogicalCallsAttemptsAndUsage(t *testing.T) {
|
|||||||
hooks.OnEventWithCall(4, context, pk.ExecutionEvent{RunID: "run-4", Kind: pk.ExecutionFinished, Attempts: 1, Usage: pk.ObservedTokenUsage{PromptTokens: pk.ObservedTokenCount{Known: false, Complete: false}, TotalTokens: pk.ObservedTokenCount{Known: false, Complete: false}}})
|
hooks.OnEventWithCall(4, context, pk.ExecutionEvent{RunID: "run-4", Kind: pk.ExecutionFinished, Attempts: 1, Usage: pk.ObservedTokenUsage{PromptTokens: pk.ObservedTokenCount{Known: false, Complete: false}, TotalTokens: pk.ObservedTokenCount{Known: false, Complete: false}}})
|
||||||
snapshot := collector.Snapshot()
|
snapshot := collector.Snapshot()
|
||||||
summary = Summarize(snapshot)
|
summary = Summarize(snapshot)
|
||||||
if summary.LogicalCalls != 4 || summary.ProviderAttempts != 4 || summary.TransientRetries != 1 || summary.StructuralRepairs != 1 || summary.Usage.Total.Value != 8 || !summary.Usage.Total.Known || summary.Usage.Total.Complete || summary.Usage.Prompt.Value != 5 || !summary.Usage.Prompt.Known || summary.Usage.Prompt.Complete || !summary.Usage.Cached.Known || summary.Usage.Cached.Complete {
|
if summary.LogicalCalls != 4 || summary.PromptKit.Attempts != 4 || summary.PromptKit.TransientRetries != 1 || summary.PromptKit.RepairCalls != 1 || summary.PromptKit.Usage.TotalTokens.Value != 8 || !summary.PromptKit.Usage.TotalTokens.Known || summary.PromptKit.Usage.TotalTokens.Complete || summary.PromptKit.Usage.PromptTokens.Value != 5 || !summary.PromptKit.Usage.PromptTokens.Known || summary.PromptKit.Usage.PromptTokens.Complete || !summary.PromptKit.Usage.CachedTokens.Known || summary.PromptKit.Usage.CachedTokens.Complete {
|
||||||
t.Fatalf("partial usage or double count: %+v", summary)
|
t.Fatalf("partial usage or double count: %+v", summary)
|
||||||
}
|
}
|
||||||
raw, err := json.Marshal(snapshot)
|
raw, err := json.Marshal(snapshot)
|
||||||
@@ -75,7 +75,7 @@ func TestObservationCollectorConcurrentAttributionAndSnapshotCopy(t *testing.T)
|
|||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
snapshot := collector.Snapshot()
|
snapshot := collector.Snapshot()
|
||||||
if len(snapshot.Calls) != calls || len(snapshot.Events) != calls || Summarize(snapshot).ProviderAttempts != calls {
|
if len(snapshot.Calls) != calls || len(snapshot.Events) != calls || Summarize(snapshot).PromptKit.Attempts != calls {
|
||||||
t.Fatalf("parallel records: calls=%d events=%d", len(snapshot.Calls), len(snapshot.Events))
|
t.Fatalf("parallel records: calls=%d events=%d", len(snapshot.Calls), len(snapshot.Events))
|
||||||
}
|
}
|
||||||
for _, call := range snapshot.Calls {
|
for _, call := range snapshot.Calls {
|
||||||
@@ -112,7 +112,7 @@ func TestRoleClientFeedsCollectorAcrossPreparationFailure(t *testing.T) {
|
|||||||
}
|
}
|
||||||
snapshot := collector.Snapshot()
|
snapshot := collector.Snapshot()
|
||||||
summary := Summarize(snapshot)
|
summary := Summarize(snapshot)
|
||||||
if count.Load() != 1 || summary.LogicalCalls != 2 || summary.ProviderAttempts != 1 || len(snapshot.Events) == 0 {
|
if count.Load() != 1 || summary.LogicalCalls != 2 || summary.PromptKit.Attempts != 1 || len(snapshot.Events) == 0 {
|
||||||
t.Fatalf("collector accounting: %+v", summary)
|
t.Fatalf("collector accounting: %+v", summary)
|
||||||
}
|
}
|
||||||
for _, event := range snapshot.Events {
|
for _, event := range snapshot.Events {
|
||||||
@@ -130,12 +130,37 @@ func TestObservationCoverageIsIndependentOfUsage(t *testing.T) {
|
|||||||
hooks := collector.Hooks()
|
hooks := collector.Hooks()
|
||||||
hooks.OnEventWithCall(1, structuredoutput.DiagnosticContext{}, pk.ExecutionEvent{RunID: "pending", Kind: pk.ExecutionAttempt})
|
hooks.OnEventWithCall(1, structuredoutput.DiagnosticContext{}, pk.ExecutionEvent{RunID: "pending", Kind: pk.ExecutionAttempt})
|
||||||
got := Summarize(collector.Snapshot())
|
got := Summarize(collector.Snapshot())
|
||||||
if got.TerminalCoverageComplete || got.Usage.Total.Known || got.Usage.Total.Complete {
|
if got.PromptKit.TerminalCoverageComplete || got.PromptKit.Usage.TotalTokens.Known || got.PromptKit.Usage.TotalTokens.Complete {
|
||||||
t.Fatalf("incomplete group=%+v", got)
|
t.Fatalf("incomplete group=%+v", got)
|
||||||
}
|
}
|
||||||
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{}, pk.ExecutionEvent{RunID: "finished", Kind: pk.ExecutionFinished, Attempts: 1, Usage: pk.ObservedTokenUsage{TotalTokens: pk.ObservedTokenCount{Value: 7, Known: true, Complete: true}}})
|
hooks.OnEventWithCall(2, structuredoutput.DiagnosticContext{}, pk.ExecutionEvent{RunID: "finished", Kind: pk.ExecutionFinished, Attempts: 1, Usage: pk.ObservedTokenUsage{TotalTokens: pk.ObservedTokenCount{Value: 7, Known: true, Complete: true}}})
|
||||||
got = Summarize(collector.Snapshot())
|
got = Summarize(collector.Snapshot())
|
||||||
if got.TerminalCoverageComplete || !got.Usage.Total.Known || !got.Usage.Total.Complete || got.Usage.Total.Value != 7 {
|
if got.PromptKit.TerminalCoverageComplete || !got.PromptKit.Usage.TotalTokens.Known || !got.PromptKit.Usage.TotalTokens.Complete || got.PromptKit.Usage.TotalTokens.Value != 7 {
|
||||||
t.Fatalf("partial coverage=%+v", got)
|
t.Fatalf("partial coverage=%+v", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestObservationRetainsNativeEvidence(t *testing.T) {
|
||||||
|
collector := NewObservationCollector()
|
||||||
|
event := pk.ExecutionEvent{
|
||||||
|
Kind: pk.ExecutionFinished, RunID: "native-run", ParentRunID: "parent",
|
||||||
|
Usage: pk.ObservedTokenUsage{
|
||||||
|
ReasoningTokens: pk.ObservedTokenCount{Value: 3, Known: true, Complete: true},
|
||||||
|
CachedTokens: pk.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
||||||
|
},
|
||||||
|
CostUSD: pk.ObservedCost{Value: 0.25, Known: true, Complete: true, Source: pk.CostSourceProvider},
|
||||||
|
}
|
||||||
|
collector.Hooks().OnEventWithCall(7, structuredoutput.DiagnosticContext{Role: "repair"}, event)
|
||||||
|
snapshot := collector.Snapshot()
|
||||||
|
if len(snapshot.Events) != 1 || snapshot.Events[0].CallID != 7 || snapshot.Events[0].PromptKit != event {
|
||||||
|
t.Fatalf("events = %+v", snapshot.Events)
|
||||||
|
}
|
||||||
|
summary := Summarize(snapshot).PromptKit
|
||||||
|
if !summary.TerminalCoverageComplete || summary.Usage.ReasoningTokens.Value != 3 || !summary.Usage.CachedTokens.Known || summary.CostUSD != event.CostUSD {
|
||||||
|
t.Fatalf("native summary = %+v", summary)
|
||||||
|
}
|
||||||
|
replayed := Summarize(ObservationSnapshot{Events: snapshot.Events}).PromptKit
|
||||||
|
if replayed.CostUSD != summary.CostUSD || replayed.Usage.ReasoningTokens != summary.Usage.ReasoningTokens {
|
||||||
|
t.Fatalf("replayed = %+v", replayed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ func TestValidatorFailureCancelsActiveAndPendingProviderWork(t *testing.T) {
|
|||||||
t.Fatalf("unfinished/cause lost: %+v", call)
|
t.Fatalf("unfinished/cause lost: %+v", call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if got := llm.Summarize(snapshot); got.ProviderAttempts != 1 {
|
if got := llm.Summarize(snapshot); got.PromptKit.Attempts != 1 {
|
||||||
t.Fatalf("attempt count: %+v", got)
|
t.Fatalf("attempt count: %+v", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user