Documentation
¶
Overview ¶
Package goal powers the "/goal" completion-condition feature: an agent loop that keeps running turns until a fast model judges a user-specified condition met. This file holds pure state + bookkeeping; no llm import.
Index ¶
- Constants
- func Continuation(condition, reason string) string
- func IsClearWord(s string) bool
- func RecoverContinuation(condition, reason string) string
- type Caps
- type State
- func (s *State) CapsExceeded(curCumTokens int) (bool, string)
- func (s *State) Clear()
- func (s *State) Set(cond string, tokenBaseline int, now time.Time)
- func (s *State) StatLine(curCumTokens int) string
- func (s *State) Status(curCumTokens int, now time.Time) string
- func (s *State) Tick()
- func (s *State) TokensSpent(curCumTokens int) int
- type Verdict
Constants ¶
const ( DefaultMaxTurns = 25 DefaultMaxTokens = 2_000_000 )
const ( AchievedPrefix = "✓ goal achieved: " StoppedPrefix = "goal: stopped (" )
Verdict markers the headless goal loop and TUI print when a goal run ends. The bench harness classifies a run by matching these prefixes in captured output, so the exact strings are a contract: change them here and every emit/parse site follows from the same const.
Variables ¶
This section is empty.
Functions ¶
func Continuation ¶
Continuation is the synthetic user message injected to keep the agent working when the goal is not yet met.
func IsClearWord ¶
IsClearWord reports whether a /goal subcommand word means clear.
func RecoverContinuation ¶
RecoverContinuation is injected after a turn that bailed because the model wedged — repeating a failing call or emitting a malformed envelope. Reframes the goal with an explicit "stop repeating, fill every required argument or switch tools" nudge so the next turn starts a fresh loop instead of the loop dying on a transient generation failure.
Types ¶
type State ¶
type State struct {
Condition string
Active bool
StartedAt time.Time
Turns int // auto-loop turns since set
TokenBaseline int // cumulative session tokens at set time
LastReason string
Caps Caps
}
State holds an active goal. Zero value = inactive.
func (*State) CapsExceeded ¶
CapsExceeded reports whether turns or token-spend passed the caps. reason is a short human string, empty when within bounds.
func (*State) Set ¶
Set activates a goal, resetting counters and timestamps. tokenBaseline is the cumulative session token count at set time so spend can be measured forward.
func (*State) StatLine ¶
StatLine is a compact one-line status-bar indicator, e.g. "goal: fix the build · t3 · 12k".
func (*State) TokensSpent ¶
TokensSpent reports tokens consumed since the goal was set, floored at 0.
type Verdict ¶
Verdict is the fast model's judgement on whether a goal condition is met.
func Evaluate ¶
func Evaluate(ctx context.Context, p llm.Provider, model, condition string, recent []types.Message) (Verdict, error)
Evaluate asks a fast model whether condition is demonstrably met based on the recent conversation. Single cheap side call, no tools. On any provider/parse error it returns Verdict{Met:false, ...} and the error.