Documentation
¶
Overview ¶
Package interjection formats and buffers mid-turn user messages.
Index ¶
Constants ¶
const LargePromptThreshold = 25_000
LargePromptThreshold matches grok-build's mid-turn truncation limit.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer holds pending mid-turn interjections keyed by run ID.
func (*Buffer) PendingCount ¶
PendingCount reports how many messages are queued for runID.
type DrainPhase ¶
type DrainPhase string
DrainPhase identifies when the runtime may drain pending interjections.
const ( // DrainBeforeSample is the start of a sampling step (before LLM call). DrainBeforeSample DrainPhase = "before_sample" // DrainAfterToolBatch is after a tool batch completes. DrainAfterToolBatch DrainPhase = "after_tool_batch" // DrainPostCompact is after context compaction reinjected reminder/context. DrainPostCompact DrainPhase = "post_compact" )
type DrainPolicy ¶
type DrainPolicy struct {
// BeforeSample drains at the start of each sampling step (default true).
BeforeSample bool
// AfterToolBatch drains after tools complete (default true).
AfterToolBatch bool
// DeferUntilPostCompact skips BeforeSample when compaction needs reminder
// reinjection; drain happens at PostCompact instead (Codex steer alignment).
DeferUntilPostCompact bool
}
DrainPolicy controls when mid-turn interjections enter the message list. Zero value means DefaultDrainPolicy().
func DefaultDrainPolicy ¶
func DefaultDrainPolicy() DrainPolicy
DefaultDrainPolicy matches historical behavior: drain before sample and after tools.
func (DrainPolicy) Allow ¶
func (p DrainPolicy) Allow(phase DrainPhase, justCompacted bool) bool
Allow reports whether draining is permitted at phase. justCompacted is true when the latest prepareMessages set NeedsReminder.
func (DrainPolicy) Normalize ¶
func (p DrainPolicy) Normalize() DrainPolicy
Normalize fills defaults for a zero-value policy.