Documentation
¶
Index ¶
- Constants
- func BuildMessages(snapshot []llm.Message, history []Entry, question, providerName, model string, ...) ([]llm.Message, error)
- func CloneMessages(messages []llm.Message) []llm.Message
- func PrepareContextSnapshot(messages []llm.Message) []llm.Message
- type Anchor
- type Entry
- type Lane
- func (l *Lane) Anchor() Anchor
- func (l *Lane) Close()
- func (l *Lane) Continuing() bool
- func (l *Lane) PrepareTurn(request TurnRequest) (*Turn, error)
- func (l *Lane) ProviderState() []byte
- func (l *Lane) RequestPrefix() []llm.Message
- func (l *Lane) Transcript() []llm.Message
- func (l *Lane) Usage() []llm.Usage
- type Result
- type Turn
- type TurnMode
- type TurnRequest
Constants ¶
const ( HistoryLimit = 20 SystemPolicy = `` /* 683-byte string literal not displayed */ ToolAttemptResponse = "Side questions cannot use tools. Ask using only the supplied conversation context." )
Variables ¶
This section is empty.
Functions ¶
func BuildMessages ¶
func BuildMessages(snapshot []llm.Message, history []Entry, question, providerName, model string, runtimeInputLimit int) ([]llm.Message, error)
BuildMessages constructs a bounded provider request. It preserves the exact main-session prefix whenever possible for prompt-cache reuse, then drops old side history before trimming main history at complete user-turn boundaries.
func CloneMessages ¶
CloneMessages returns a point-in-time deep copy without changing provider protocol metadata. Request construction performs sanitization once after all context fragments have been assembled.
Types ¶
type Anchor ¶ added in v0.9.52
type Anchor struct {
Messages []llm.Message
Provider runboundary.ProviderContext
DurableAnchorID int64
Durable bool
}
Anchor is the main-conversation boundary a side lane branches from. It is one value with one owner: the messages, the provider state they were captured with, and the provider/model identity that state belongs to always travel together, so new identity can never end up attached to an old snapshot.
type Entry ¶
type Entry struct {
Question string `json:"question"`
Response string `json:"response"`
CreatedAt time.Time `json:"created_at"`
Usage llm.Usage `json:"usage"`
}
func AppendHistory ¶
type Lane ¶ added in v0.9.52
type Lane struct {
// contains filtered or unexported fields
}
Lane is one side discussion: the boundary it branched from, its own transcript, and — when the provider can branch from a captured boundary — its own provider session carried across turns.
A lane is a lifecycle object, not data. Callers must cancel any running turn and then Close it on panel close, panel clear, and every boundary invalidation.
func (*Lane) Close ¶ added in v0.9.52
func (l *Lane) Close()
Close releases the lane's provider and drops its anchor and transcript. A turn that is still running owns the provider lifetime and releases it itself, so callers should cancel before closing to avoid a detached background process.
func (*Lane) Continuing ¶ added in v0.9.52
Continuing reports whether the lane holds its own provider session. While it does, the lane is anchored: it no longer re-reads the main boundary.
func (*Lane) PrepareTurn ¶ added in v0.9.52
func (l *Lane) PrepareTurn(request TurnRequest) (*Turn, error)
PrepareTurn decides, for one question, whether the lane continues, is created by branching the anchor's provider session, or falls back to a bounded replay.
Eligibility lives here, once, rather than at each call site.
func (*Lane) ProviderState ¶ added in v0.9.52
ProviderState returns the lane provider's exported transport state. The live clone is not serializable; this is, which is what promotion needs.
func (*Lane) RequestPrefix ¶ added in v0.9.52
RequestPrefix returns everything the lane's provider has already been given, plus its replies. The next turn appends to it so the provider's recorded resume offset and transcript digest still line up.
func (*Lane) Transcript ¶ added in v0.9.52
Transcript returns the lane's own conversation, without the main transcript it branched from. Promotion writes exactly these into a child session.
type Turn ¶ added in v0.9.52
type Turn struct {
// contains filtered or unexported fields
}
Turn is one prepared lane turn.
func (*Turn) Abandon ¶ added in v0.9.52
func (t *Turn) Abandon()
Abandon releases a prepared turn that will never run. A branch created for it is dropped; an already established lane session is kept, because nothing was sent to it.
func (*Turn) Request ¶ added in v0.9.52
Request exposes the prepared provider request for assertions and debugging.
func (*Turn) Run ¶ added in v0.9.52
Run performs this turn's single provider request and folds the result back into the lane.
Ephemeral is decided here and nowhere else: only a turn whose provider came from the boundary fork seam runs non-ephemerally, so a Responses helper turn can never chain onto the live conversation by convention or by mistake.
type TurnMode ¶ added in v0.9.52
type TurnMode int
TurnMode reports how one lane turn reaches the model.
type TurnRequest ¶ added in v0.9.52
type TurnRequest struct {
Question string
Anchor Anchor
History []Entry
ProviderKey string
Model string
ReasoningEffort string
ReasoningMode string
// InputLimit is the runtime's own input budget, when it has one. Zero falls
// back to the provider/model helper budget.
InputLimit int
// AllowFork gates lane creation from the anchor's live provider session.
AllowFork bool
// ForkStillAllowed is re-evaluated immediately before a branch streams. The
// gate cannot be a single snapshot: a main run can start between preparing a
// branch and launching it, and branching a session another process is writing
// is exactly what AllowFork exists to avoid. Returning false downgrades the
// prepared branch to the bounded replay path.
ForkStillAllowed func() bool
// ForkSource is the live provider the lane branches from. It is never used
// for the request itself, and is never mutated.
ForkSource llm.Provider
// NewProvider builds a standalone provider for the bounded replay path.
NewProvider func(providerKey, model string) (llm.Provider, error)
// SessionID is the term-llm session a promoted lane belongs to. Empty for an
// unpromoted lane, which keeps its turns out of session state entirely.
SessionID string
}
TurnRequest is everything one lane turn needs. Both the TUI and the web runtime build this instead of repeating the provider/budget/request prelude.