feat(protocol): distinguish reported chat metrics from unavailable values
This commit is contained in:
@@ -461,11 +461,22 @@ type ChatStep struct {
|
||||
Intermediate bool `json:"intermediate,omitempty"`
|
||||
}
|
||||
|
||||
// ChatUsage is the token and cost total of a turn.
|
||||
// ChatUsage carries native usage snapshots. Rich metrics are pointers so zero
|
||||
// reported by a harness remains distinguishable from an unavailable value.
|
||||
// Session snapshots replace previous values; consumers must not sum updates.
|
||||
type ChatUsage struct {
|
||||
InputTokens int `json:"input_tokens,omitempty"`
|
||||
OutputTokens int `json:"output_tokens,omitempty"`
|
||||
Cost float64 `json:"cost,omitempty"`
|
||||
InputTokens int `json:"input_tokens,omitempty"`
|
||||
OutputTokens int `json:"output_tokens,omitempty"`
|
||||
Cost float64 `json:"cost,omitempty"`
|
||||
Scope string `json:"scope,omitempty"`
|
||||
TotalTokens *int64 `json:"total_tokens,omitempty"`
|
||||
ContextTokens *int64 `json:"context_tokens,omitempty"`
|
||||
ContextWindow *int64 `json:"context_window,omitempty"`
|
||||
CostUSD *float64 `json:"cost_usd,omitempty"`
|
||||
OutputTokensPerSecond *float64 `json:"output_tokens_per_second,omitempty"`
|
||||
// RateBasis distinguishes a generation interval from a whole turn (which
|
||||
// can include tools/waits). Never estimate tokens from text/character counts.
|
||||
RateBasis string `json:"rate_basis,omitempty"`
|
||||
}
|
||||
|
||||
// ChatShell is the state of one shell command the agent started, carried by a
|
||||
|
||||
Reference in New Issue
Block a user