Documentation
¶
Overview ¶
Package contextsummary turns the messages a compaction drops into one validated, bounded summary document, through one bounded provider.Completer call. A summary failure is a caller-visible error; no structural fallback exists. Compaction policy lives in contextplan; the loop wiring lives in agentloop.
Index ¶
Constants ¶
const MaxExcerptTotalBytes = 16 * 1024
MaxExcerptTotalBytes bounds the whole source-excerpt section of one summarize prompt.
const MaxFieldBytes = 2 * 1024
MaxFieldBytes bounds every individual Summary text field and every list item.
const MaxItems = 32
MaxItems bounds every Summary list.
const SummaryMessageName = "context-summary"
SummaryMessageName is the provider.Message.Name of the injected summary message. Compaction preserves it through PreserveNames.
const SummaryTimeout = 20 * time.Second
SummaryTimeout bounds one summarize call.
Variables ¶
var ( // ErrNilCompleter is NewSummarizer's error for a nil Completer. ErrNilCompleter = errors.New("contextsummary: completer is required") // ErrNoMessages is Summarize's error for an empty message list. ErrNoMessages = errors.New("contextsummary: no messages to summarize") // ErrInvalidReply is Summarize's error when the reply fails // strict parsing or Summary.Validate. ErrInvalidReply = errors.New("contextsummary: reply failed strict parsing or validation") // ErrCallFailed is Summarize's error when the Completer call // itself fails. ErrCallFailed = errors.New("contextsummary: summary call failed") )
Sentinel errors; test with errors.Is.
Functions ¶
func SummaryMessage ¶
SummaryMessage renders s as one RoleUser message named SummaryMessageName, whose Content is s.Render().
func TokenEstimate ¶
TokenEstimate prices n bytes at n/4 tokens, minimum one for non-zero input, zero for zero input.
Types ¶
type Summarizer ¶
type Summarizer struct {
// contains filtered or unexported fields
}
Summarizer adapts one provider.Completer to summary generation.
func NewSummarizer ¶
func NewSummarizer(c provider.Completer) (*Summarizer, error)
NewSummarizer binds one Completer. A nil Completer wraps ErrNilCompleter.
type Summary ¶
type Summary struct {
Objective string
State string
Decisions []string
OpenWork []string
Risks []string
}
Summary is one validated summary document. Data only: no tool, policy, or credential fields.
func (Summary) Render ¶
Render returns the deterministic text form of s: one labeled line or bullet per field, in field order.