Skip to content

refactor(agent): a watch asks the API what became of its input (DEP-8992) - #715

Open
robstolarz wants to merge 6 commits into
mainfrom
rob/dep-8992-watch-reads-session-input
Open

robstolarz wants to merge 6 commits into
mainfrom
rob/dep-8992-watch-reads-session-input

Conversation

@robstolarz

@robstolarz robstolarz commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

A sketch, built to test a theory. Not to be merged or released until the API side is live. Replaces #714: the same change as one commit, plus review fixes.
depot agent watch --after-input, create --watch and send --watch worked out whether an input had its reply from the messages in the session view: a state machine with grace timers that followed the turn by position. They now ask the API, which answers from the session's stored record of the input (GetSessionInput):

  • pending or placed: the watch goes on.
  • answered: the watch takes the message the API names (from the frame when it is whole, read by its id otherwise) and exits 0. The API names only a reply: a run that ended on a tool step or on an error reads unanswered there, and the watch exits 1 with the reason. The watch also checks the role and tool calls itself.
  • unanswered or withdrawn: exit 1 with the reason (stopped, model error, no reply, cancelled).

Change for scripts: cases that exited 1 with "the session moved past the input before its reply was seen" now keep waiting, and exit 2 if --timeout runs out. --until-idle alone keeps what is left of the state machine. Hand-written source: +227 / −223; tests: +180 / −331. This makes #700 (DEP-8781) unnecessary; it can be closed with a pointer here when this lands.

Post-deploy test plan

Once the API serves GetSessionInput, with a binary built from this branch:

  1. depot agent create "..." --watch: exit 0 with the reply.
  2. depot agent send <session> "<ask for a reply of several thousand words>" --watch -o json: exit 0, and reply holds the whole text, not the view's cut of it.
  3. Watch a turn and stop it with depot agent stop <session>: exit 1, "the turn was stopped before the agent replied".
Notes
  • Against an API without the read the watch fails with the RPC's error, so the CLI release waits for the API.
  • Checked before that with a binary from this branch against the live API: watch --until-idle (which does not use the new read) exits 0 with the reply.
  • A session at rest whose input still reads as placed is read again (session, then input) up to three times, 10 seconds apart; if it is still at rest with no work showing, the watch exits 1 with "the turn ended without a reply".

🤖 Generated with Claude Code

https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe


Note

High Risk
Changes core watch/create/send behavior, exit codes, and API coupling for automation; depends on server GetSessionInput being deployed before release.

Overview
depot agent watch --after-input, create --watch, and send --watch no longer infer whether an input finished from the bounded session view. They call the new GetSessionInput RPC and treat its stored outcome as source of truth: keep waiting on pending/placed, exit 0 with the named answer message on answered (via frame text or GetSessionMessage when truncated), and exit 1 with structured messages on unanswered / withdrawn or when the answer is not a real assistant reply.

The large view-position turn state machine (base seq, pickup polling, “input lost from cut view”) is removed along with pre-watch GetSession newestSeq / base wiring. --until-idle still ends from view heuristics only. Renderer gains Reply and Said so replies still print when the input scrolled out of the view. Proto and Connect stubs add GetSessionInput; tests are rewritten around mocked input outcomes.

Script-visible change: failures like “the session moved past the input before its reply was seen” become continued waiting until --timeout (exit 2). Requires a live API that implements GetSessionInput.

Reviewed by Cursor Bugbot for commit cef3b90. Bugbot is set up for automated code reviews on this repo. Configure here.

…992)

watch --after-input, create --watch and send --watch read the outcome of
the awaited input from GetSessionInput and take the reply from the
message that read names, instead of working both out from the messages
in the session view. The turn state machine now only serves --until-idle.

- The reply comes from the frame when the frame holds it whole, and is
  read by id otherwise; a failed read falls back to the frame's text.
- A message that is not the assistant's, or that calls a tool, is not
  reported as the reply.
- A session at rest while the input still reads as placed is read again,
  up to three times a grace period apart.
- A refused read is reported under the RPC that was refused.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe
@linear-code

linear-code Bot commented Nov 27, 2026

Copy link
Copy Markdown

DEP-8992

Comment thread pkg/cmd/agent/watch.go Resolved

@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 pkg/cmd/agent/watch.go Resolved
Comment thread pkg/cmd/agent/watch.go Resolved

@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 comment

Risk: medium. Not approved; Cursor Bugbot reported two unresolved potential issues that need human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

…EP-8992)

- A reply read by id is printed after its role is checked, and the
  status line is repeated after a reply printed late.
- A session at rest whose input still reads as placed after every look
  ends the watch as a run without a reply.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe
Comment thread pkg/cmd/agent/watch.go Resolved
Comment thread pkg/cmd/agent/watch.go Resolved

@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 pkg/cmd/agent/watch.go Resolved
…n as ended (DEP-8992)

Each extra look at an input a resting session still holds first reads
the session again. A session back at work, or a view that shows work
under way, is left to its later frames.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review completed

Nothing new to post: everything this review found is already covered by existing comments on this pull request or didn't merit a separate one.

@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 pkg/cmd/agent/watch.go Resolved

@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 comment

[!NOTE]
🤖 Cursor Grok 4.6 responding on behalf of Jacob Gillespie

Risk: medium. Not approved; Cursor Bugbot reported one unresolved potential issue that needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No new blocking issues. 1 optional suggestion (a nit or a note on pre-existing code) was found and not posted. Nothing in this review needs a push before merging.

@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 using default effort 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 a15bb37. Configure here.

Comment thread pkg/cmd/agent/watch.go Resolved
… failed (DEP-8992)

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe

@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 comment

[!NOTE]
🤖 Cursor Grok 4.6 responding on behalf of Jacob Gillespie

Risk: medium. Not approved; Cursor Bugbot reported one unresolved potential issue that needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

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

Note

🤖 Cursor Grok 4.6 responding on behalf of Jacob Gillespie

Risk: medium. Approved; Cursor Bugbot completed successfully with no unresolved findings that need human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

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.

1 participant