Documentation
¶
Overview ¶
Package reflect runs the post-task learning pass: it asks the model to distill durable lessons from a finished transcript and returns them as pitfalls for the knowledge base. Parse failures yield no lessons (not an error); only a transport failure surfaces as ReflectionError.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lessons ¶ added in v0.4.2
type Lessons struct {
Pitfalls []knowledge.Pitfall
Facts []string
// Parsed reports whether a JSON object was actually read out of the model's
// reply. It separates "the model looked and found nothing to learn" from "we
// could not read what it said" — two different failures with two different
// fixes, which were indistinguishable because both surfaced as an empty
// Lessons and neither was logged at all.
Parsed bool
// Reply is what came back when nothing could be parsed, for the log. Empty
// once Parsed is true.
Reply string
}
Lessons is what a reflection pass distills: general tool pitfalls (saved to the workspace's lesson store) and durable facts about THIS project (saved alongside them, folded into the prompt next time). Both are per workspace and both are wiped by /clear.
type ReflectionError ¶
type ReflectionError struct{ Err error }
ReflectionError wraps a host-level failure of the reflection pass (the model call itself failing).
func (*ReflectionError) Error ¶
func (e *ReflectionError) Error() string
func (*ReflectionError) Unwrap ¶
func (e *ReflectionError) Unwrap() error
type Reflector ¶
type Reflector struct {
// Model and Provider name the connection for the log. Without them a failed
// pass says only that "the model" looped, and the first question — which one,
// the task's or a reflect profile's — could not be answered from the log at
// all. Optional; empty is fine.
Model string
Provider string
LLM llm.Chatter
Lite bool
// Prefix, when set, sends every reflection call as the next message of the
// run itself — Prefix is the run's own messages as the server last saw them,
// Tools the run's own tool list — so a caching local server answers from the
// prefix it already holds instead of prefilling a summary under a different
// system prompt. A reply that is not the JSON asked for falls back to the
// standalone call. Only meaningful when LLM talks to the same server and
// model the run did.
Prefix []llm.Message
Tools []map[string]any
// contains filtered or unexported fields
}
Reflector distills lessons from a transcript using a Chatter. Lite uses a simpler, facts-only prompt — for a small local model that loops on the full two-part ask.
func (*Reflector) Reflect ¶
Reflect distills lessons from t. A turn with no tool use (a plain chat) has nothing to learn, so it skips the model call — no point making a small model reason over an empty run.
Lite runs two narrow calls instead of one combined one (see the prompts above); a failure of either is not fatal to the other, since half the lessons beats none.