feat: conversion-driven extensions — resolvers, DefineTool, hooks, ops controls
Phase 9a (ADR-0014): Registry.RegisterResolver for dynamic tiers; DefineTool[Args] typed tools; Usage cache/reasoning detail fields wired through anthropic/openai/google; WithPromptCaching (Anthropic cache_control); agent supervision hooks (WithMaxStepsFunc, WithSteer, WithCompactor, WithToolErrorLimits + ErrToolLoop); health Bench/Unbench/Snapshot; ChainConfig.Observer failover events. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -18,10 +18,22 @@ const (
|
||||
FinishOther FinishReason = "other"
|
||||
)
|
||||
|
||||
// Usage reports token accounting for one request.
|
||||
// Usage reports token accounting for one request. InputTokens and
|
||||
// OutputTokens are always totals; the detail fields break out portions of
|
||||
// those totals where the provider reports them (0 = not reported).
|
||||
type Usage struct {
|
||||
InputTokens int
|
||||
OutputTokens int
|
||||
|
||||
// CacheReadTokens is the portion of InputTokens served from the
|
||||
// provider's prompt cache.
|
||||
CacheReadTokens int
|
||||
// CacheWriteTokens is the portion of InputTokens written to the
|
||||
// provider's prompt cache.
|
||||
CacheWriteTokens int
|
||||
// ReasoningTokens is the portion of OutputTokens spent on
|
||||
// thinking/reasoning.
|
||||
ReasoningTokens int
|
||||
}
|
||||
|
||||
// Total returns input plus output tokens.
|
||||
@@ -31,6 +43,9 @@ func (u Usage) Total() int { return u.InputTokens + u.OutputTokens }
|
||||
func (u *Usage) Add(o Usage) {
|
||||
u.InputTokens += o.InputTokens
|
||||
u.OutputTokens += o.OutputTokens
|
||||
u.CacheReadTokens += o.CacheReadTokens
|
||||
u.CacheWriteTokens += o.CacheWriteTokens
|
||||
u.ReasoningTokens += o.ReasoningTokens
|
||||
}
|
||||
|
||||
// Response is the canonical generation result.
|
||||
|
||||
Reference in New Issue
Block a user