Unify structured call completion and retain typed failures

This commit is contained in:
2026-11-16 14:27:54 +00:00
parent e98e525b5c
commit c2c8050bc8
18 changed files with 313 additions and 186 deletions

View File

@@ -50,17 +50,13 @@ type Exchange struct {
}
type Response struct {
Exchange *Exchange `json:"-"`
Execution outcomes.ExecutionCounts `json:"execution"`
Content json.RawMessage `json:"content,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
PromptTokens int `json:"prompt_tokens,omitempty"`
CompletionTokens int `json:"completion_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
Prompt PromptMetadata `json:"prompt"`
Prepared *PreparedSnapshot `json:"prepared,omitempty"`
FinalContent string `json:"final_content,omitempty"`
Exchange *Exchange `json:"-"`
Execution outcomes.ExecutionCounts `json:"execution"`
Content json.RawMessage `json:"content,omitempty"`
Model string `json:"model,omitempty"`
Prompt PromptMetadata `json:"prompt"`
Prepared *PreparedSnapshot `json:"prepared,omitempty"`
FinalContent string `json:"final_content,omitempty"`
}
// PreparedSnapshot is the exact rendered request snapshot. Its messages may
@@ -81,8 +77,7 @@ type CacheControl struct {
TTL string `json:"ttl,omitempty"`
}
// CallRecord brackets one logical operation, including preparation. Content
// is present only when a model returned it; consumers must protect it.
// CallRecord brackets one logical operation, including preparation.
type CallRecord struct {
RequestedPromptID string `json:"requested_prompt_id,omitempty"`
CallID uint64 `json:"call_id"`
@@ -90,8 +85,6 @@ type CallRecord struct {
Prompt PromptMetadata `json:"prompt"`
Started time.Time `json:"started"`
Finished time.Time `json:"finished,omitempty"`
Prepared *PreparedSnapshot `json:"prepared,omitempty"`
FinalContent string `json:"final_content,omitempty"`
Failure FailureKind `json:"failure,omitempty"`
}