Skip to content

feat(plan): Keep a durable plan per Conversation with delta updates - #3457

Merged
BYK merged 26 commits into
mainfrom
feat/durable-plan
Nov 16, 2026
Merged

BYK merged 26 commits into
mainfrom
feat/durable-plan

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The plan of a Conversation is now durable. updatePlan stores items in Postgres, and the model sees changes that others make as append-only <plan-delta> blocks.

In local:web:f7dacf3ebf6bfba61b9dfd4c, a coordinator with about 10 child agents lost its backlog twice. Compaction dropped a queued brief (one rolling 1,000-word summary), and a sandbox reset wiped /vercel/sandbox/backlog.md. updatePlan was never called: the rule framed it as a per-Turn plan, and it stored nothing anyway.

What changes

  • Storage: new junior_plan_items table (migration 0114_plan_items), keyed to the Conversation. An item has an id, title, notes, status (pending, in_progress, blocked, done, cancelled), one assignee (the Conversation's own agent, one of its child agents, or a User), and a version. One global sequence gives ids and versions, so forks never reuse a version that the model saw. A partial unique index allows one in_progress item per assignee.
  • Tool: hard cutover of updatePlan to add / update / remove by id. A call with no changes lists the open items. A child assignee is checked against this Conversation's children, as stopAgent does. A person resolves by email or mention, as Review items do.
  • Deltas, Lore-style: the model's own edits get no block, because the tool call and result are already in history. Changes by a person since the highest version in history go in a <plan-delta> turn-context section with only the changed items and their author. Blocks are never rewritten. The tags only keep runtime text apart from person text: each block is plain lines that start with Plan version N., and person text is escaped so it cannot close a tag.
  • Compaction: the summary message ends with one <plan> snapshot of the open items, read from the database. Compaction drops older deltas, and later deltas build on the snapshot. plan-continuation.ts and <open-plan> are gone.
  • Steering: the <planning> rule and the updatePlan description now say the plan holds only work that outlives the Turn: queued work, work handed to a child agent (with the child as assignee), and work assigned to a person. The per-Turn checklist for "substantial work with dependent steps" is gone. The rule still says never to keep a backlog in a file. The tool description holds the per-call rules.
  • Loading status: updatePlan no longer sets it. On main, the in-progress step of the per-Turn checklist was the loading status. With no per-Turn steps, the agent's own in_progress item is queued work that it picks up, not a phase of the Turn, so reportProgress alone sets the status.
  • Dashboard: Conversation Details shows a Plan card with the open items, then up to five recently closed ones, each with its status and assignee. Participants can mark an item done, cancel it, or reopen it (PATCH /api/conversations/:id/plan/:itemId). The agent sees that change as a delta on its next Turn. A change does not start a Turn. If the viewer cannot see private content, titles, notes, and names are redacted.
  • Purge: purge deletes plan items for every visibility, because titles and notes are conversation content.
  • TERMINOLOGY.md adds Plan and Plan item.

Nothing to migrate by hand. Plans in old tool-call arguments are not imported. An old compacted summary keeps its <open-plan> text, but nothing reads it anymore.

Design choices

  • Scope: only work that outlives the Turn. Other harnesses have dropped per-Turn todo tools because newer models track short multi-step work without them, and the tool and its reminders cost context. The coordination case is the one that still needs saved state.
  • Term: "Plan" / "Plan item", not "Task". In TERMINOLOGY, Task is a kind of child Conversation. I kept the name updatePlan. "Assignee" keeps its Review item meaning and adds the agent and child-agent cases.
  • Child access: read-only. A child agent sees its parent's open items, with their assignees, in the parent entry of listAgents (self is the child, parent is the parent's own agent). The parent comes from the runtime context, never from model arguments, so a child reads only its own parent's plan. A child's updatePlan changes only its own plan, and the child tells the parent about changes with messageAgent or its result. A <child-agent-run> rule says this, so only child Turns pay for it.
  • Person vs. agent: a person can change only the status in the dashboard. When the agent then replaces a status that a person set, the agent's change wins, and the updatePlan result lists it in replaced_person_changes. A User that Plan items reference cannot be deleted, as with Conversation participants.
  • Delta trigger: a person changes a status in the dashboard. Runtime state changes, such as a child finishing, already reach the model as <agent-result>, so they do not write to the plan.

Screenshots

Plan card in Conversation Details (mock dashboard, a Conversation the viewer takes part in):

Light Dark
Plan card, light Plan card, dark

Status menu for a participant:

Plan item menu

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot requested a review from BYK November 14, 2026 22:47
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 16, 2026 4:21pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

41 screenshot changes — 41 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Picker · Desktop
Automation Skill Picker · Desktop
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Attachment Zoom · Mobile
Conversation Attachment Zoom · Mobile
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Show 12 more changed screenshots
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Details Sheet · Mobile
Conversation Details Sheet · Mobile
Changed
Conversation Details Sheet Light · Mobile
Conversation Details Sheet Light · Mobile
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log · Desktop
Conversation Event Log · Desktop
Changed
Conversation Fork Dialog · Desktop
Conversation Fork Dialog · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Object Links Light · Desktop
Conversation Object Links Light · Desktop
Changed
Conversation Pending Attachment · Desktop
Conversation Pending Attachment · Desktop
Changed
Conversation Question Dismissed · Desktop
Conversation Question Dismissed · Desktop
Changed

23 more changed screenshots in Frameshift.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/junior/src/chat/plan/store.ts Resolved
BYK added a commit that referenced this pull request Nov 16, 2026
#3501)

When someone who did not create an Automation asks to add themselves
("remind me to bring the agenda"), the model sometimes drops the person
and saves "…, including a reminder to bring the agenda". The scheduler
eval "when a requester who did not create a reminder adds themselves"
catches this whenever its model calls run live, for example on
#3457.

The `instruction` param told the model not to write "me", and listed a
non-creator requester only as part of "every other person". So when the
model removed "me", it removed the person too.

- `instruction` param: keep every person the user means, including "me".
The creator is "the Automation creator". Anyone else, including a
requester who is not the creator, is a Slack mention. The text is the
same length as before.
- `requireAutomationTaskText`: reject new `me`/`my`/`myself` in text
that a non-creator edits, and give their mention in the error, because
each run reads "me" as the creator. With this check, the model can keep
"me" and still get the exact fix. Text that the creator writes, and text
that was already saved, still pass.

The eval is unchanged: a non-creator requester named by mention is what
the product promises.

The other scheduler failure on #3457, "another channel member requests
creator credentials", is not a steering gap. Each time, its second model
call came from the same Roach recording (same tool call id and cost).
That recording ends in `AI provider error: timeout`, so all 4 retries
fail. Roach records any response that is not a 429 or 5xx, so a 200
stream that ends in a provider error can be saved. This PR changes the
`instruction` param text that this call reads through `searchTools`, so
after #3457 rebases, that request no longer matches the bad recording.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ad2394ed655a61fa4ad5737287e2e9b74 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ad2394ed655a61fa4ad5737287e2e9b74)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ad2394ed655a61fa4ad5737287e2e9b74/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
@thomasjiangcy

Copy link
Copy Markdown
Contributor

some research on other harnesses: https://junior-prod.sentry.dev/conversations/local%3Aweb%3A04ce65a9e55f0884b9d75459

i think it's probably something worth considering. though maybe we're not fully aligned on what plan means and what it's solving.

sentry-junior Bot and others added 3 commits November 16, 2026 14:14
Drop the per-Turn checklist case from the planning rule and the updatePlan
description. The plan now holds queued work, work for a child agent, and
work for a person. With no per-Turn steps, the agent's own in-progress item
no longer drives the loading status; reportProgress owns it.

Co-Authored-By: BYK <[email protected]>
@sentry-junior

sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@thomasjiangcy thanks for the research. It changed the scope of this PR.

Your summary splits these tools into three jobs: keeping the model on track, showing progress, and coordination. This PR is about coordination, the one job that your research says still needs saved state (Claude Tasks, agent teams). So the plan is saved in Postgres, items have ids and assignees (this agent, a child agent, or a person), child agents can read their parent's plan, and people can change an item's status from the dashboard. The agent sees those changes as <plan-delta>.

The problem it targets: a long coordinator Conversation, local:web:f7dacf3ebf6bfba61b9dfd4c (about 10 child agents and 19 compactions), lost queued work twice.

  • Compaction dropped a queued brief for a child agent, and that work was never done.
  • A sandbox reset wiped a backlog file.

The old updatePlan could not help there. Like Codex's tool, it saved nothing, and the model never called it in that session.

Your findings raised two questions, and @BYK has decided both:

  1. The per-Turn checklist is gone. The plan now holds only work that outlives the Turn: queued work, work handed to a child agent (the child is the assignee), and work assigned to a person. The <planning> rule and the updatePlan description no longer ask for a checklist of steps the Turn finishes. A new eval checks that a short multi-step Turn makes no updatePlan call. With no per-Turn steps, updatePlan no longer sets the loading status; reportProgress does.
  2. Context cost. A Turn that doesn't need the plan should no longer call the tool. The <plan-delta> and <plan> blocks show up only when a person changed the plan or after a compaction.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d9bff7d. Configure here.

Plan writes from the agent and from the dashboard now bump the
Conversation's detail version, so other open Conversation Details views
reload the Plan card.
Comment thread packages/junior/src/chat/plan/prompt.ts Resolved
The <plan> and <plan-delta> tags only isolate runtime text from person
text. The version is now a plain first line, and items are plain lines
instead of XML elements with attributes.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File an issue to revisit our XML-style injection usage. If we need to use it, we then should invest into a proper XML parser as we do have XML escaping in the contents and we tend to start using XML features such as tag attributes.

I'd prefer avoiding XML and sticking with Markdown or some other simpler thing tbh.

@BYK
BYK enabled auto-merge (squash) November 16, 2026 16:25
@BYK
BYK merged commit 670262b into main Nov 16, 2026
46 of 48 checks passed
@BYK
BYK deleted the feat/durable-plan branch November 16, 2026 16:31
@sentry-junior

sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@BYK Filed #3514 to revisit the XML-style tags in model-read prompt text. It lists where the escaping helpers and attributes are used, the attribute contract in policies/prompt-markers.md, and your proposal: a proper XML parser if the tags stay, or preferably Markdown or something simpler.

sentry-junior Bot added a commit that referenced this pull request Nov 17, 2026
AGENTS.md rules now say which check enforces each one, so a correction for a
rule that only review enforces shows up as a repeat.

Agents keep fixing missing information with new hooks, resolvers, and
lookups instead of fixing the source, as in #3610,
#3404, and #3457. No check can tell a needed
abstraction from a speculative one, so correctness-complexity.md names the
case.

Co-Authored-By: David Cramer <[email protected]>
BYK pushed a commit that referenced this pull request Nov 21, 2026
…its check (#3612)

## Baselines can only shrink

The ratchet baselines (`type-assertions`, `await-in-loop`,
`test-architecture`, `typecheck-coverage`, `migration-locks`,
`tool-descriptions`, `file-length-exceptions`) already say "do not add
entries". But when a check trips, an agent can still add an entry and
the check passes. Review caught this on #3564 and
#3035, both from @BYK. It merged without review in
#3460, #3226, and #3206.

`pnpm baseline-growth:check` is now part of `pnpm lint`. It compares
each baseline to the merge base with `origin/main` and fails when a
rule's total goes up. The error names the baseline, the rule, and the
entries that caused it. Totals are counted per rule, so a file that
moves or splits still passes. A rule or baseline that is new in the
change is skipped, because that is how a new check gets adopted. The CI
lint job now uses `fetch-depth: 0` so it has a merge base.

`tool-error-classification-baseline.txt` is left out because it is an
allowlist of approved system errors and grows on purpose.

## Use data the system already has before you add plumbing

Agents fix missing information with new hooks, resolvers, and lookups
instead of using data the system already stores, as in
#3610, #3404, and #3457.
No check can tell a needed abstraction from a speculative one, so
`policies/correctness-complexity.md` now names this case.

## Generate deterministic output in code, not prompt text

Agents fix deterministic behavior with prompt or policy text.
#3610 first tried to fix PR links with a GitHub system
prompt change, and @dcramer rejected it: "We know if it's a pull request
or an issue. We should just be generating the right link." The bot name
in prompts (#3404) had to become a check, and
#3438 was told not to add policy text when a rule can
enforce it. `policies/agent-steering.md` now says to generate links,
IDs, and formats in code.

## Rule table

The AGENTS.md rules are now a table that says what enforces each rule. A
correction for a rule marked "Review" shows that the rule is a repeat
and needs a higher-level fix.

## Open decision

- There is no override for baseline growth. If a reviewer approves a
growth, they have to change the check. Should there be an approved
override, such as a PR label?

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A9da30a1e94fc26f2b83022cfd8dd95fc -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A9da30a1e94fc26f2b83022cfd8dd95fc)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A9da30a1e94fc26f2b83022cfd8dd95fc/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 6a5c65f1 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants