/goal command: the user sets an objective, the agent keeps working toward it, and the UI can show progress with stop/resume controls.
Behavior
When a client starts a goal, the agent-server:- Finds the live conversation
EventService. - Rejects the request if the conversation or another goal is already running.
- Creates a
GoalControllerfrom the objective andmax_iterations. - Starts a background task and returns immediately.
- Emits
ConversationStateUpdateEventwithkey="goal"andstatus="running". - Sends the objective as a normal user message into the same conversation history.
- Runs the agent, judges the resulting events, and either emits
complete/cappedor sends a follow-up prompt and loops.
Endpoints
All endpoints are under the agent-server API prefix.
Start requests include the objective and an optional iteration cap:
max_iterations defaults to 10 and must be at least 1.
Status Events
Clients should render goal progress from streamedConversationStateUpdateEvent events where key == "goal". The value includes:
These status events are persisted with the conversation events, so resume can work after a server restart.
Stop and Resume
POST /goal/stop cancels the background goal driver if one is running. The cancel path records a status="interrupted" goal event, so the UI can stop showing the goal as active and the goal can be resumed later. It does not delete conversation history.
POST /goal/resume reads the last persisted goal status. It only resumes statuses that are not terminal; a goal with status="complete" or status="capped" is not resumable. Resume rebuilds the controller with the same objective and stored iteration, then continues with a resume prompt.
Stopping is graceful. If a model call is already in flight, it may finish before the conversation becomes idle.
Error Handling
There is no dedicated
GET /goal endpoint. To restore UI state on load, read the conversation events and use the latest ConversationStateUpdateEvent with key="goal".
