Documentation
¶
Overview ¶
This file implements the /goal command (mirrors pi-goal / Claude Code's goal mode): given a high-level objective, golder runs the agent autonomously — re-prompting it turn after turn from the loop's follow-up seam — until the model declares the goal done (goal_complete), reports a true impasse (goal_blocked), or a safety guard (max turns / no-progress) or the token budget stops it.
/goal is intercepted in the REPL loop rather than routed through a slash Action closure because it must run agent streams and mutate the shared context and goal state — none of which a pure string→string Action can do, exactly like /compact and /fork. It reaches the session's collaborators and mutable state through the cli.Host contract, so it need not import the concrete replDeps aggregate that assembles them.
Scope: core autonomous continuation plus an optional token budget. Goal state lives only in the session's in-memory GoalState (host.Goal()); it is not persisted across process restarts.
Index ¶
- func FollowUp(host cli.Host) func(context.Context, *agentcore.AgentContext) []agentcore.AgentMessage
- func ParseObjective(args string) (objective string, budget int, err error)
- func Reminders(base *agenttool.ToolRegistry, state *agenttool.GoalState) *runtime.ReminderRegistry
- func RenderOutcome(out io.Writer, snap agenttool.GoalSnapshot)
- func RenderStatus(out io.Writer, state *agenttool.GoalState)
- func RunGoal(setCancel func(context.CancelFunc), out io.Writer, host cli.Host, line string)
- func Start(state *agenttool.GoalState, objective string, budget int)
- func ToolRegistry(base *agenttool.ToolRegistry, state *agenttool.GoalState) *agenttool.ToolRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FollowUp ¶
func FollowUp(host cli.Host) func(context.Context, *agentcore.AgentContext) []agentcore.AgentMessage
FollowUp returns the loop's GetFollowUpMessages hook for a goal run: on each settle it accounts for the turns produced since the previous one (their output tokens and whether any tool ran), records the iteration on the goal state, and re-prompts the model to continue until a guard trips. It is exported so the TUI can drive the same autonomous loop with its own run seam.
Auto-compaction can shrink agentCtx.Messages in place between settles, dropping its length below the tracked mark; the mark is clamped so the slice never goes out of bounds (the compacted turn's tokens are then under-counted, which is acceptable for a soft budget guard).
func ParseObjective ¶
ParseObjective splits an optional leading "--tokens N" flag from the objective text (see parseGoalObjective). Exported for the TUI.
func Reminders ¶
func Reminders(base *agenttool.ToolRegistry, state *agenttool.GoalState) *runtime.ReminderRegistry
Reminders returns the reminder registry for a goal run: the goal reminder plus the todo reminder when a todo tool is present. Exported for the TUI.
func RenderOutcome ¶
func RenderOutcome(out io.Writer, snap agenttool.GoalSnapshot)
RenderOutcome writes the one-line result banner for a settled goal run. Exported for the TUI.
func RenderStatus ¶
RenderStatus writes a summary of the current goal state (the bare /goal output). Exported for the TUI.
func RunGoal ¶
runGoal parses and dispatches a /goal invocation. setCancel publishes the active run's cancel func so the REPL's SIGINT handler can interrupt an autonomous run (same plumbing as a normal turn).
func Start ¶
Start records a new objective on the goal state. Exported for the TUI, which starts the run through its own async seam.
func ToolRegistry ¶
func ToolRegistry(base *agenttool.ToolRegistry, state *agenttool.GoalState) *agenttool.ToolRegistry
ToolRegistry returns a registry holding every tool from base plus the two goal-control tools (goal_complete / goal_blocked), so an autonomous run can end itself. Exported for the TUI's goal run.
Types ¶
This section is empty.