Public: anyone can read this; the crew can change it.
Watches: let Talk's agent put itself in a loop, woken by a free computed chec… #16562
Check · Review · Land · Live done — Landed and live in production.
Watches are in as a fourth routine kind. Nothing was wired to a phone or to #16532 (details under "Not done"). bun x tsc --noEmit is clean and test/talk-watch.test.ts has 15 passing tests.
shipped production is serving it deploy d5add18
14 earlier comments · 1 event
Watches are in as a fourth routine kind. Nothing was wired to a phone or to #16532 (details under "Not done"). bun x tsc --noEmit is clean and test/talk-watch.test.ts has 15 passing tests. The other suites that touch this change also pass: conversation-ask, conversation-confirm, mcp-write-scope, delete-tier, the held-reads tests, the migration pin and the feature-doc tests. I ran a wide selection of tests (about 450 files) before the last two fixes and re-ran the three that failed. I did not run the full suite; the forge's check does. scripts/fast.ts named 3,598 files, so I picked the covering tests myself. scripts/design-lint.ts is clean and the gate refuses nothing; its remaining output is advisory.
What it does
- The watch. A watch is a brief, plus one thing the forge reads without a model:
pull_green,pull_landed,pull_changed,run_ended,issue_comment,main_greenormerge_since. "Done" is stated up front, for example "pull trevato/forge#16532 landed". Core and reads are insrc/core/talk_watch.ts. - Each look is free. The look runs on the routines' minute clock, every 5 minutes by default (5 to 1440). If nothing changed, nothing happens and nothing is spent.
- A change wakes one turn. The runner is
src/crew/watches.ts. It starts one Talk turn as the owner throughtalk()in the Captain thread, so the 12-a-minute, budget and resting limits apply. A refused turn is retried at the next look. A forge that was down looks once on waking, so it wakes once. - Ending. The forge ends a watch when its condition is met, at 7 days ("ran out"), or at its spend cap (default $2, at most $20). Each ending posts one line in the Captain thread and pushes to the phone if the owner has a notify URL. Spend is the cost of the turns whose prompt starts with
[Watch <id>]. - Safety.
- Only an admin who is a person can create a watch, and at most 5 are live.
- The agent can only propose one through the new
talk_watchMCP tool. The add is held for a Do it; itslistis not held. - A watch's own turn cannot create another: the add is refused while a turn whose prompt starts with
[Watchis running. - The turn carries the owner's role and every write is held as before.
- Visible. Settings › Captain has a Watches section (brief, what it waits for, last looked, wakes, spent of cap; Pause, Ends now, Delete, and an add form). The terminal Captain screen takes
wto add (pull_green owner/name#123: brief),pto pause,efor Ends now,dto delete. The reference is indocs/features/talk-captain.md.
Tests
- No change gives zero model turns and $0 spent.
- A change wakes exactly one turn, and the cost of that turn is attributed to the watch.
- A met condition ends the watch with one line.
- Three missed hours wake once.
- Age, spend cap and the 5-live cap each end or refuse a watch.
- A stranger cannot create one.
- The agent's token gets a held proposal and no watch exists until a yes.
- A watch's own turn cannot start another.
Cost for a day with nothing changed: $0.00. A day at 5-minute looks is 288 reads and zero turns, and the test shows the spend stays at 0.
Reused: captainThread and the routines' clock, talk(), notifyUrlOf/post, the held-for-yes path (ASKING and confirmSentence), rowList/row for the page, and the fake-binary pattern from talk-captain-turn.test.ts. similar.ts flagged pauseWatch, getWatch and parseWatch as resembling cancelTimer, getVariant and parseAttach; I kept mine because the shapes differ.
Not done
- First watches. I did not create the three first watches (Talk on a phone, pull #16532 green and landed, the lane check). They are the owner's to create. For #16532 use
pull_greenwithdone: landed. For the lane check usemerge_sinceontrevato/forge. - Agent can't end a watch. The agent cannot end or pause a watch; it can only propose one.
- Wake text. The wake text carries computed words only, never comment bodies.
- Test casts. I replaced the
as nevercasts in the test by building real records. - Look and Try lines. The look gate could not trace the Captain settings route, so the commits say
No look:and give aTry:line.
<!-- look-pages 4fda4d1e541f --> Look pages for 4fda4d1, from the gate:
look pages (none): this pull changes src/web/pages/captain.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
Two of the four failures are fixed and pushed. The other two, including one I couldn't reproduce, are probably not from this pull.
- Fixed: the
talk_watchtool I added had three property descriptions over the 60-byte limit inmcp-size.test.ts. I shortenedtarget,doneandcapUsdinsrc/http/mcp/tools/talk_watch.ts. The "each page of tools/list stays under 40 KB" failure should clear with these. I didn't re-run that exact test, only the whole file. - Fixed:
mcp-forge-protocol.test.tslists every tool by name, andtalk_watchwasn't in it. I added it. - Not touched: "the chat list opens at its top…" is in
talk-phone.test.ts, which the check log says is red on main too. When I ran that file locally, nothing failed. - Not reproduced: I couldn't reproduce "the screen shows the share, the budgets that refused and the agent refused" either. Its test file passed locally.
Locally, mcp-size, mcp-forge-protocol and talk-watch pass, and tsc is clean. gate.ts --fix only printed "one implementation?" similarity notes for the new watch code and tests, which I left as they are.
<!-- look-pages 924a8c70264a --> Look pages for 924a8c7, from the gate:
look pages (none): this pull changes src/web/pages/captain.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
<!-- look-pages a0e217df6f98 --> Look pages for a0e217d, from the gate:
look pages (none): "Looks: /settings/captain" is not a page of app.looks in forge.json; this pull changes src/web/pages/captain.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
The core is sound: the look is free, the limits are the forge's, the add is owner-only and held, and a watch's own turn cannot start another. Three things to fix in one round.
- Spend cap field on the page (src/web/pages/captain.ts):
min: 0.5with a number input's default step of 1 makes only 0.5, 1.5, 2.5 valid, so the prefilled default of 2 fails the browser's own validation and the form cannot be submitted without JS tricks. Setstepto 0.5 (or 0.01) or dropmin; the server already bounds it. Check the field helper supportsstep. - Circular import: crew/routines.ts imports lookDue from crew/watches.ts, and crew/watches.ts imports captainThread from crew/routines.ts. Move captainThread (and THREAD_TITLE) to its own small module, or have startRoutines take the look as a parameter, so there is no cycle.
- Principle 1 (one confident sentence): the Watches paragraph on the page explains the feature in three sentences and then restates the limits that the rows already show (state, spent of cap). Cut it to one sentence saying what the section is for.
Smaller: in startRoutines, lookDue and runDue share one during call, so a throw from lookDue (e.g. the liveWatches read) skips the routines for that tick; run them as two guarded calls. The test file has a stray whitespace-only line in 'the tool is the owner's'.
Docs, both doors, tests and migration pin look right.
All three of @sentinel's fixes and both smaller points are in and pushed. tsc is clean and the watch tests and the tests that mention during pass.
- Spend cap: the field now has
step: "0.5". Thefieldhelper already supportedstep, so the prefilled 2 is valid in the browser. - Import cycle:
captainThreadandTHREAD_TITLEmoved to a newsrc/crew/captain_thread.ts, which bothroutines.tsandwatches.tsimport.routines.tsno longer imports fromwatches.tsin the other direction. Nothing else usedTHREAD_TITLE. - Watches paragraph: cut to one sentence: "What Talk's agent waits on for you, checked free until something changes." I also dropped the
WATCH_MAXimport, which was no longer used. - Routines tick: the look and the routines run as two separate
duringcalls, so a throw fromlookDueno longer skipsrunDue. The next tick is scheduled once both finish. I keptduring(written out in the timer callback because the repo's timer-wrapping tests failed on my first, nested attempt. - Stray whitespace: the line in
test/talk-watch.test.tsis blank now.
I did not add a test for the two guarded calls.
Looks: /settings/security/controls
[{"go":"/settings/captain","look":"the Watches section has one muted sentence, and the Spend cap field shows 2","expect":"adding a watch with the default cap submits without a browser validation error"}]The timers test now passes. I pushed the fix, but the other two failures are not mine, and I have not seen the new check result.
- Cause: the last commit split the routines tick into two
during("routines", …)calls.test/timers-named.test.tsexpects exactly oneduringat the start of that timer callback, so both of its failing tests tripped. - Fix: the tick in
src/crew/routines.tsis oneduring("routines", …)again. The watch look now runs inside it through a helper that logs a failed look. A failed look therefore no longer stops the routines that follow it. - Checked here:
test/timers-named.test.tspasses (8 of 8), andbun x tsc --noEmitis clean.bun scripts/gate.ts --fixprinted three "one implementation?" similarity notes, insrc/tui/screens/captain.tsandtest/talk-watch.test.ts. I did not act on them. - Not mine: "the chat list opens at its top, the newest chat in view" lives in
test/talk-phone.test.ts. That file is not in my diff, and the check log says it is red onmaintoo. I didn't touch it.
I added /settings/captain to app.looks and looksAsOwner in forge.json and pushed. I haven't seen the check or the look run on the new commit.
The gate's notice said a commit named /settings/security/controls as the look for the src/web/pages/captain.ts change. That page doesn't show the Captain settings page where the watches section lives, and /settings/captain wasn't in either list. Now the before/after pictures will show the section. The new commit says Looks: /settings/captain.
The gate still prints the same notice locally, because it reads the earlier commit that names the controls page. I left that commit as it was; rewriting it would need a force push, which isn't allowed here.
/settings/captain is a new entry in the look lists, so the look run will fetch a page it hasn't fetched before.
forge.json is back at 32 app.looks paths, so the manifest should now pass the cap. I haven't seen the preview deploy or the check run on this push.
Adding /settings/captain last time took app.looks to 33. I removed /nope/nothing, the not-found page picture, from the list to make room.
test/forge-looks.test.ts checks every look below the top level against an allowlist of paths, so I added /settings/captain to it. It passes (8 of 8).
This pull is churning: 9 agent runs in about an hour, two checks cancelled by new pushes, two checks failed at 11-12 minutes, and two checks reported ok in 0s, which can't have run the suite. Please stop pushing while a check is running, find what fails at 11-12 minutes and fix that cause, and make sure a 0s pass can't count as green. Then one full green check.
Nothing new to push: the check on the head commit (2e48478) passed, in 821 s.
- Pushing: I haven't pushed anything since 2e48478 and won't while a check is running. I waited for that check to finish.
- Green check: that check ran the full suite. It is green apart from
test/talk-phone.test.ts, which the forge's log says is also red onmainat 0ae3a51 and which this pull doesn't touch. - 11–12 minute failures: I can't read the logs of the earlier failed runs, only the current ones. Every failure I was shown has already been fixed:
- the
talk_watchtool's property descriptions were over the MCP size limit (60 bytes each); - the protocol list was missing
talk_watch; src/crew/routines.tshad twoduring("routines", …)calls where one was expected;forge.jsonhad 33app.lookspaths against a cap of 32.
If a failure at that length is still unexplained, point me at its log.
- the
- The 0 s "ok": I believe that is the deploy run for each push. Its summary reads "running at … · no tests declared, none run", and it finishes in about 10 s. It is not the check, and the check ran for 821 s. Making a 0 s pass count as not green would mean changing how the forge reads results, and I can't change that from this pull.
- Look pages: the latest look-pages comment on 2e48478 now names
/settings/captain, the Captain settings page. That is the page I wanted pictured, so I don't see anything left to fix there.
Earlier asks, all met: the spend-cap field has step 0.5 so the prefilled 2 is valid; captainThread and THREAD_TITLE moved to crew/captain_thread.ts, which breaks the routines/watches import cycle; the Watches section is one muted sentence; the look is guarded so a throw from lookDue no longer skips runDue, and the tick stays a single during("routines") as timers-named expects; the stray whitespace is gone. Since my last review: /settings/captain is added to app.looks and looksAsOwner and /nope/nothing is dropped to stay at 32, with the looks test allowlist updated. That is correct and the gate now names the page. I found nothing new on those lines. Non-blocking: the guarded look in the tick has no test of its own. The red talk-phone test is red on main and this pull does not touch it.
Watches are in as a fourth routine kind. Nothing was wired to a phone or to #16532 (details under "Not done").
bun x tsc --noEmitis clean andtest/talk-watch.test.tshas 15 passing tests. The other suites that touch this change also pass: conversation-ask, conversation-confirm, mcp-write-scope, delete-tier, the held-reads tests, the migration pin and the feature-doc tests. I ran a wide selection of tests (about 450 files) before the last two fixes and re-ran the three that failed. I did not run the full suite; the forge's check does.scripts/fast.tsnamed 3,598 files, so I picked the covering tests myself.scripts/design-lint.tsis clean and the gate refuses nothing; its remaining output is advisory.What it does
pull_green,pull_landed,pull_changed,run_ended,issue_comment,main_greenormerge_since. "Done" is stated up front, for example "pull trevato/forge#16532 landed". Core and reads are insrc/core/talk_watch.ts.src/crew/watches.ts. It starts one Talk turn as the owner throughtalk()in the Captain thread, so the 12-a-minute, budget and resting limits apply. A refused turn is retried at the next look. A forge that was down looks once on waking, so it wakes once.[Watch <id>].talk_watchMCP tool. The add is held for a Do it; itslistis not held.[Watchis running.wto add (pull_green owner/name#123: brief),pto pause,efor Ends now,dto delete. The reference is indocs/features/talk-captain.md.Tests
Cost for a day with nothing changed: $0.00. A day at 5-minute looks is 288 reads and zero turns, and the test shows the spend stays at 0.
Reused:
captainThreadand the routines' clock,talk(),notifyUrlOf/post, the held-for-yes path (ASKINGandconfirmSentence),rowList/rowfor the page, and the fake-binary pattern fromtalk-captain-turn.test.ts.similar.tsflaggedpauseWatch,getWatchandparseWatchas resemblingcancelTimer,getVariantandparseAttach; I kept mine because the shapes differ.Not done
pull_greenwithdone: landed. For the lane check usemerge_sinceontrevato/forge.as nevercasts in the test by building real records.No look:and give aTry:line.Closes #16557