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

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy d5add18

opened this

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_green or merge_since. "Done" is stated up front, for example "pull trevato/forge#16532 landed". Core and reads are in src/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 through talk() 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_watch MCP tool. The add is held for a Do it; its list is not held.
    • A watch's own turn cannot create another: the add is refused while a turn whose prompt starts with [Watch is 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 w to add (pull_green owner/name#123: brief), p to pause, e for Ends now, d to delete. The reference is in docs/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_green with done: landed. For the lane check use merge_since on trevato/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 never casts 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 a Try: line.

Closes #16557

14 earlier comments · 1 event
commented

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_green or merge_since. "Done" is stated up front, for example "pull trevato/forge#16532 landed". Core and reads are in src/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 through talk() 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_watch MCP tool. The add is held for a Do it; its list is not held.
    • A watch's own turn cannot create another: the add is refused while a turn whose prompt starts with [Watch is 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 w to add (pull_green owner/name#123: brief), p to pause, e for Ends now, d to delete. The reference is in docs/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_green with done: landed. For the lane check use merge_since on trevato/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 never casts 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 a Try: line.
commented

<!-- 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
commented

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_watch tool I added had three property descriptions over the 60-byte limit in mcp-size.test.ts. I shortened target, done and capUsd in src/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.ts lists every tool by name, and talk_watch wasn'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.

commented

<!-- 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
commented

<!-- 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
commented

<!-- look-pages 030f046129d7 --> Look pages for 030f046, from the gate:

  • look pages (named): this pull changes src/web/pages/captain.ts; a commit names /settings/security/controls
commented

The gate accepted the look: it now reads "named", with /settings/security/controls taken from the commit. Nothing is left to change on this pull, and I pushed nothing new.

Changes requested — before the latest push

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.

  1. Spend cap field on the page (src/web/pages/captain.ts): min: 0.5 with 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. Set step to 0.5 (or 0.01) or drop min; the server already bounds it. Check the field helper supports step.
  2. 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.
  3. 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.

commented

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". The field helper already supported step, so the prefilled 2 is valid in the browser.
  • Import cycle: captainThread and THREAD_TITLE moved to a new src/crew/captain_thread.ts, which both routines.ts and watches.ts import. routines.ts no longer imports from watches.ts in the other direction. Nothing else used THREAD_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_MAX import, which was no longer used.
  • Routines tick: the look and the routines run as two separate during calls, so a throw from lookDue no longer skips runDue. The next tick is scheduled once both finish. I kept during( 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.ts is 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"}]
commented

<!-- look-pages 630af1c9e4a7 --> Look pages for 630af1c, from the gate:

  • look pages (named): this pull changes src/web/pages/captain.ts; a commit names /settings/security/controls
commented

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.ts expects exactly one during at the start of that timer callback, so both of its failing tests tripped.
  • Fix: the tick in src/crew/routines.ts is one during("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.ts passes (8 of 8), and bun x tsc --noEmit is clean. bun scripts/gate.ts --fix printed three "one implementation?" similarity notes, in src/tui/screens/captain.ts and test/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 on main too. I didn't touch it.
commented

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.

commented

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).

commented

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.

commented

<!-- look-pages 2e48478f28a1 --> Look pages for 2e48478, from the gate:

  • look pages (named): this pull changes src/web/pages/captain.ts; a commit names /settings/captain
commented

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 on main at 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_watch tool's property descriptions were over the MCP size limit (60 bytes each);
    • the protocol list was missing talk_watch;
    • src/crew/routines.ts had two during("routines", …) calls where one was expected;
    • forge.json had 33 app.looks paths against a cap of 32.

    If a failure at that length is still unexplained, point me at its log.

  • 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.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs