Skip to content

fix(server): give Prime all queued follow-ups when its run would stop - #241

Merged
morgan-wowk merged 2 commits into
TangleML:mainfrom
Hargun3:hargun/prime-followup
Dec 4, 2026
Merged

morgan-wowk merged 2 commits into
TangleML:mainfrom
Hargun3:hargun/prime-followup

Conversation

@Hargun3

@Hargun3 Hargun3 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When Prime is busy, messages sent to it (from people, River, and its own workers' end-of-run reports) wait in Pi's follow-up queue. Pi's default follow-up mode is one-at-a-time: each time Prime would stop, Pi gives it just one queued message, so a backlog is worked through one message per turn. In a research session Prime was about 85 minutes behind, answering a 05:05 UTC message at 06:28 UTC, and River worked around it by sending one message that "replaces everything": https://shopify.slack.com/archives/C0CFQF9EB41/p1796020520354999

Change

When Tangent starts a Prime process, it sends Pi's RPC command set_follow_up_mode with mode all. When Prime would stop, it now gets the whole backlog in one turn and can see that a newer message replaces an older one. Sub-agents are not sent the command. It is sent from spawnAgent, so every Prime start gets it: the first start, a crash respawn, and a model-change respawn. docs/server/orchestrator.md now lists the command with the other stdin RPC commands.

How tested

  • New unit test in piAgentManager.test.ts: Prime gets set_follow_up_mode all, a sub-agent does not, and a crash-respawned Prime gets it again. The test fails without the change. Two existing tests now skip the new command when they look at stdin.
  • pnpm typecheck, pnpm lint (0 errors), pnpm build, prettier --check, and pnpm --filter @tangent/server test (849/849) all pass.
  • Checked against Pi 1.6.0, the version in the Dockerfile. The command exists, and get_state goes from one-at-a-time to all. With a mock model, 3 messages queued during a run reached the model in 1 request instead of 3.
  • Merged into current main (eadf39b, which includes fix(server): say why a run failed in the run-error notice #231): typecheck, lint and build pass, and the server tests pass (862/862). With feat: tell a human when their message to a busy Prime is queued #232 merged on top as well: 865/865.
  • End to end on a real local Tangent server, with real Pi 1.6.0 and a real model (claude-haiku-4-5): Prime was given a 60-second task, and 3 follow-ups were sent while it ran. With this change, all 3 reached Prime together and got one reply, in 1 turn. With the change reverted, they took 3 turns, one reply each. Both cases were one Pi run. A throwaway HOME was used, so no real settings were touched.

Limits

  • Pi 1.6.0 saves this mode to its global settings ($HOME/.pi/agent/settings.json). Other Pi processes that share HOME start with all too. In the container (HOME=/tmp) that means sub-agents started after Prime. When you run Tangent locally, it changes your own ~/.pi/agent/settings.json. Pi 1.6.0 offers no way to set the mode without saving it.
  • This does not make a long run shorter, and it does not detect a run that has gone silent. fix(server): flag a run that goes quiet, and stop it after a stall timeout #233 would have caught silent runs but was closed without merging. feat: tell a human when their message to a busy Prime is queued #232 (open) tells the sender their message is queued.
  • The saved setting stays after this change is reverted. To undo it on your machine, remove followUpMode from ~/.pi/agent/settings.json.
  • Not tried on a deployed Shell, or in a long research session with many worker reports. Whether batching them changes how well Prime handles each report is a judgement call for reviewers.

Pi's default follow-up mode, one-at-a-time, hands a busy agent one queued
follow-up each time it would stop, so a backlog of messages to Prime was
worked one message per turn. Prime now starts with set_follow_up_mode all
and gets the whole backlog in its next turn.

Pi 1.6.0 also saves this mode to its global settings, so other Pi
processes sharing HOME start with it too.
@Hargun3
Hargun3 marked this pull request as ready for review December 4, 2026 09:45
@Hargun3
Hargun3 requested a review from a team as a code owner December 4, 2026 09:45
@morgan-wowk
morgan-wowk merged commit 78d3283 into TangleML:main Dec 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants