Adopt PromptKit v0.23.0 conversations and execution accounting

This commit is contained in:
2026-11-15 01:25:55 +00:00
parent d28b560265
commit d98d419b36
25 changed files with 689 additions and 924 deletions

View File

@@ -31,7 +31,7 @@ type Request struct {
Schema responseschema.Key `json:"schema"`
Context DiagnosticContext `json:"context"`
CaptureExchange bool `json:"-"`
Replay *Replay `json:"-"`
ContinueFrom *Exchange `json:"-"`
}
// PromptMetadata is the execution snapshot returned by the runtime when available.
@@ -44,33 +44,23 @@ type PromptMetadata struct {
Model string `json:"model,omitempty"`
}
// Exchange holds a section's original prepared conversation for read-only replay.
// Exchange is an opaque immutable conversation owned by the runtime adapter.
type Exchange struct {
PromptID string
Variables map[string]string
Messages []Message
FinalContent string
}
// Replay carries a section exchange and the prior turns of one repair branch.
type Replay struct {
Exchange *Exchange
Turns []Message
State any
}
type Response struct {
Exchange *Exchange `json:"-"`
RepairInstruction []Message `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"`
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"`
}
// PreparedSnapshot is the exact rendered request snapshot. Its messages may
@@ -108,3 +98,16 @@ type CallRecord struct {
type Client interface {
CompleteStructured(ctx context.Context, req Request, out any) (Response, error)
}
// Turn delivers a completed correction request, or its failure. The initial
// callback has no response. A failure is terminal for this coordination.
type Turn struct {
Response *Response
Err error
}
// Coordinator delegates bounded conversation progression to the runtime.
// Returning no request stops the branch; requesting beyond the budget exhausts it.
type Coordinator interface {
Coordinate(context.Context, *Exchange, int, func(context.Context, Turn) (*Request, error)) (bool, error)
}