Skip to content

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

Closed
robstolarz wants to merge 7 commits into
mainfrom
rob/dep-8992-watch-reads-input-outcome
Closed

robstolarz wants to merge 7 commits into
mainfrom
rob/dep-8992-watch-reads-input-outcome

Conversation

@robstolarz

@robstolarz robstolarz commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

A watch asks the API what became of its input (DEP-8992)

A sketch, built to test a theory. Not to be merged or released until the API side is live.

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 as the answer (from the frame when it is whole, read by its id otherwise) and exits 0. A message that is not the agent's own, or that calls a tool, is not reported as a reply.
  • unanswered or withdrawn: exit 1 with the reason (stopped, model error, cancelled).

What is left of the state machine serves --until-idle alone, which asks about the session, not an input. Hand-written source: +174 / −223. Tests: +166 / −331 (seven tests that pinned the deleted heuristics went; three tests of the outcomes replaced them).

This makes #700 (DEP-8781) unnecessary: that change reads the same record from two new fields of the session view and keeps the old inference as a fallback. It can be closed with a pointer here when this lands.

Post-deploy test plan

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

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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe


Note

Medium Risk
Changes core agent watch/create/send behavior and adds a hard dependency on a new RPC; --until-idle path is largely preserved but input waits fail if the API is absent.

Overview
Watch flows that wait on a specific input (watch --after-input, create --watch, send --watch, launch --watch) no longer infer completion from the session view. They call the new GetSessionInput RPC and branch on outcome (pending/placed keep waiting; answered loads the named message; unanswered/withdrawn exit with structured errors).

The old view-based machinery is removed: base/newestSeq/beforeFirst, pickup grace for inputs missing from truncated views, and the turn heuristics (place, answered, lost, cut-view failure modes). --until-idle still uses a slimmed turn.settled on the view only.

Supporting changes: proto/connect GetSessionInput types; awaited/answer in watch.go; Renderer.Reply for transcript/whole-message handling; wholeMessage now returns role; watch errors can attribute the failing RPC via rpcError. Tests swap heuristic cases for API-outcome coverage and expect GetSessionInput on watch credential paths.

Requires the API to expose GetSessionInput before this CLI can ship for input-scoped watches.

Reviewed by Cursor Bugbot for commit d09552c. 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 the reply by the message id it
names, instead of working both out from the messages in the session view.
The turn state machine now only serves --until-idle.

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

@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

[!NOTE]
🤖 Cursor Grok 4.6 responding on behalf of Cursor Approval Agent

Risk: medium. Left a non-blocking comment; not approved. Cursor Bugbot reported two unresolved findings, including a high-severity watch failure, so 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.

Findings marked 🟡 are optional suggestions and need no follow-up push.

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

A frame that only streams more of a reply no longer costs a read, and a
reply the frame holds whole is taken from it rather than read by id.

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 Cursor Approval Agent

Risk: medium. Left a non-blocking comment; not approved. Cursor Bugbot still has an unresolved medium-severity watch hang finding, so 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.

Code review found no new issues

No new issues were found in this update; 3 findings from earlier reviews are still open above.

Still open from earlier reviews (3):

  • 🔴 pkg/cmd/agent/watch.go:261 — A watch can hang until its 30-minute timeout when the session goes idle before the API records the input as answered. a…
  • 🔴 pkg/cmd/agent/watch.go:328 — --watch can exit 0 with a subagent's report, or a tool step, given as the agent's reply. This happens if the API's answ…
  • Also unresolved: 1 minor or pre-existing.

If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.

robstolarz and others added 4 commits November 27, 2026 13:13
… read (DEP-8992)

- The reply comes from the frame when the frame holds it whole; a failed
  read of a longer reply falls back to the frame's text instead of failing
  the watch.
- A message that is not the assistant's, or that calls a tool, is not
  reported as the reply.
- An idle session whose input still reads as placed gets one more read
  after the grace period instead of waiting for the timeout.
- 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
…s an error reply an error (DEP-8992)

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQk3K7GpvQg7ySXyCrirEe
…lds (DEP-8992)

Up to three more reads a grace period apart, and the next frame asks
again. A reply whose input has left the view is printed.

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.

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 0cf557c. Configure here.

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. Left a non-blocking comment; not approved. Cursor Bugbot reported an unresolved medium-severity finding on the current head, so 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.

1 optional suggestion (a nit or a note on pre-existing code) was found and not posted.

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

Risk: medium. Approved. Cursor Bugbot completed successfully on this head 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.

@robstolarz

Copy link
Copy Markdown
Contributor Author

Replaced by #715: the same change as one commit, with the proto copy matching the API's. This branch is kept.

@robstolarz robstolarz closed this Nov 27, 2026
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