Repository navigation
Hold a stand-in's work for agents whose memory never came over - #223
Merged
Merged
Conversation
A secondary standing in for its primary ran the nightly dreams and the automations of every agent, including agents whose folder on that computer was never synced (MEMORY.md still the template), and with prompts naming folders under the primary's home that don't exist there. - Scheduled and caught-up automations, condition checks, event automations and scheduled or early dreams wait for the primary when the agent's memory never came over from it or the prompt names folders missing here - Paths under another computer's home in automation prompts map to this computer's home - The first memory merge between two computers keeps the owner's version of a file both have (the primary's, or the controller's) instead of combining it with a stand-in's template or first dream - A device that receives memory from its peer records the agreed state too, so it counts as synced and has a base for the next merge
…is back Runs that wait for a usage limit or budget reset and follow-ups in those chats would continue by themselves days later and repeat what the primary already did. What waits for the human stays. The path test no longer assumes /Users/Shared exists (it doesn't on Linux CI).
…en the primary is back
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the primary of a device group went away, the secondary standing in ran the 03:00 dream batch and the scheduled automations of every agent. That included agents whose folder had never been synced to that computer, so their MEMORY.md was still the template. Those dreams wrote "first dream" memories rebuilt from activity logs, and on the next first-time merge with the primary they would have been combined with the primary's real MEMORY.md. Automation prompts also named paths under the primary's home folder, which don't exist on the stand-in.
Changes
remote/standIn.tsstandInHold(agentId, prompt?): while standing in, the agent waits for the primary when its memory never came over from the primary (norunner_memoryrow for it) or when its prompt names folders that aren't on this computerremote/localPaths.ts: in automation prompts, a/Users/<other>/or/home/<other>/that doesn't exist here maps to this computer's home. On the primary this changes nothingmergeMemorytakes anowner: on the first sync (no base), the owner's version of a file both sides have wins, and files only one side has are kept.exchangeMemorymakes the primary the owner when a secondary syncs with it, and the local side otherwise (the primary, or a controller with its runner)runner_memoryas well, so that agent counts as synced there and later merges have a baseremote/devices.tsstopWaitingWork: when the primary is back, the secondary stops work that would continue by itself later. This covers runs waiting for a usage limit or budget reset in chats it took over from the primary, runs of automations, heartbeats, checks, dreams and follow-ups it started while standing in, and follow-ups in taken chats. Without this, a stand-in whose Claude account hit its weekly limit kept those runs paused and would have resumed them days later, repeating outreach the primary had already done. Pauses that wait for the human (a question, a pause they chose) stay. Stopped runs show the reason in the chatTests
pnpm -r typecheckbun test test/local-paths.test.ts test/scheduler.test.ts test/remote-snapshot.test.ts test/dreaming.test.ts test/automations.test.ts test/remote-link.test.ts test/devices-e2e.test.ts: all pass. This adds tests for the stand-in hold, path mapping and the owner-wins first mergebun test test/stand-in-waiting.test.ts test/pause.test.ts: limit-paused taken chats, stand-in automation runs and follow-ups stop; human pauses and older runs stay/Users/Sharedexists, which made CI fail on Linux