Skip to content

feat(agent): goals run in the background and call the person only when needed - #339

Merged
ziyan merged 9 commits into
mainfrom
background-goals
Oct 6, 2026
Merged

ziyan merged 9 commits into
mainfrom
background-goals

Conversation

@ziyan

@ziyan ziyan commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Generated by AI, do not review or read yet.

A goal is now background work: it runs in a conversation of its own, keeps an activity log and the things it made, and writes into the main conversation only when it needs the person. Design: docs/planning/background-goals-execplan.md; decision: docs/decisions/20261005-goals-run-in-the-background-and-call-only-when-needed.md.

Architecture after this change: goal turns run in the goal's own conversation, the worker's sweep writes a waiting goal into the main conversation once, and the Goals tab, the CLI and the goal tool share five operations

A goal that needs the person: its question is said once in the main chat, the person answers there, and the answer is passed back to the goal

  • Migration 0148: goal_title and goal_surfaced_at on conversations, agent_goal_activity, agent_goal_artifact; conversations of the kind goal.
  • Goal turns run in the goal's conversation, may start background work (which wakes the goal), and log progress, waits, stalls and failures; mail rules, reminders and alert mutes made there are its artifacts.
  • surfaceGoals writes a waiting goal into the main conversation once, under [goal needs you]; the main prompt lists waiting goals, and the goal tool's tell passes the answer on. Goals of their own send no mail.
  • ListAgentGoals, GetAgentGoal, StartAgentGoal, TellAgentGoal, SetAgentGoalState; the goal tool and teanode agent goal list|show|start|tell|done|drop|reopen use them. The per-conversation goal is removed: no goal menu on a chat, no goal arguments on conversations, no set in the tool.
  • Goals tab: Needs you, Tracking, Done, Start a goal, and a page per goal; the drawer links a goal's call to it.

Test plan: Go tests for starting, running out of the main conversation, surfacing once, telling, dropping and reopening, and the API's permissions; web tests for the tab and a goal's page; make lint-ci. On a dev server with a real model, a goal asked a question, was answered in the main chat and was met; checked in a browser at 1400 and 390 pixels, light and dark.

Changelog

Added

  • Goals run in the background: each in a conversation of its own, with a status line, an activity log and the schedules, rules, reminders and mutes it made. Your main conversation hears from a goal only when it needs you, and you can answer it right there. The Goals tab groups them as Needs you, Tracking and Done, and teanode agent goal lists, starts, answers and closes them.

Removed

  • a goal set on a conversation you chat in. The drawer no longer offers one; ask your agent to keep at something, or start a goal on the Goals tab.

ziyan added 5 commits October 5, 2026 19:10
…n needed

A goal is a conversation of its own, of the kind goal, with a title, a
one-line status, an activity log and the things it made (migration
0148). Its turns run there, may start background work, and record mail
rules, reminders and alert mutes they make. When a goal comes to need
the person, the worker's sweep says so once in the main conversation;
the main turn's prompt lists waiting goals, and the goal tool's tell
passes the answer on. ListAgentGoals, GetAgentGoal, StartAgentGoal,
TellAgentGoal and SetAgentGoalState back the tool and 'teanode agent
goal'. Goals are no longer put on conversations the person chats in.
…ts log

Needs you, Tracking and Done, each goal with its status line; a goal's
page shows what it is for, what it made and what happened, with a box
to answer it and Done, Drop and Reopen. The drawer draws a goal's call
for the person with a link to it, and its goal menu starts a goal in
the background.
…eir own send no mail

Found running goals on a dev server: the model passed its status as
status, not text, so the goal tool takes status for note and wait; the
drawer hid the goal's call with the working notes; and the mail a
waiting goal sent was itself alerted on, saying the same thing twice.
@ziyan ziyan added the AI-generated Opened by an AI assistant label Oct 5, 2026
ziyan added 4 commits October 5, 2026 20:09
The leftover set action could only clear a goal left on a conversation
from before, but a model asked to set a goal reached for it. The idea
that offers goals now sees goals of their own as tried.
One kind of goal is left, the background goal. The drawer's goal menu
on a chat, the goal arguments of StartAgentConversation and
UpdateAgentConversation, the in-progress listing, the turn count, the
goal-change lines in transcripts and the goal tool's set are gone; only
goal conversations take turns. The tool's guidance says a hope is not a
goal to start.
…ere it was asked

A goal whose work is on a clock takes no turns of its own while it has
an enabled schedule; the schedule's runs are its turns, in its
conversation, ending with the goal tool. Schedules become a goal's when
made in it, passed to start, or moved with take_schedule
(MoveAgentScheduleToGoal, teanode agent goal take-schedule). A goal
whose schedule is switched off gets a turn again. The goal remembers
the conversation it was asked in (migration 0149) and its page links
it; the agent is told to write goal text without ids. The activity
timeline's dots and line now line up, and long text wraps.
A done or dropped goal's schedule no longer runs, and a goal's own turn
cannot reopen a goal that is done. A mailed schedule is no goal's clock,
and a schedule made or edited in a goal's conversation answers there.
An answer to a goal on a schedule earns a turn at once, and a goal on a
schedule takes no forced second turn. Only the person moves a schedule
into a goal. The goal operations run in the request's transaction, so a
start that fails leaves no goal behind; saying a waiting goal is checked
under the row's lock. The goal tool answers with goalState and
goalStatus.
@ziyan
ziyan marked this pull request as ready for review October 6, 2026 13:24
@ziyan
ziyan merged commit 22378ae into main Oct 6, 2026
12 checks passed
@ziyan
ziyan deleted the background-goals branch October 6, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated Opened by an AI assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant