fix(bridges): 30→60 min watch cap + cancel upstream replica on timeout#33
Merged
Merged
Conversation
Findings from Lark Admin room review: last turn there hit the 30-min timeout while the agent was *actively* making progress through multi- step MCP config cleanups. Session has 317 cumulative steps / 40 turns — this is real heavy ops work, not a runaway loop. Two fixes: **#1 Bump MAX_WATCH_DURATION_MS from 30 → 60 min** (both bridges) Lark Admin's "Watch timed out — agent ran longer than 30 min" was a false-positive cap on legitimate work. 60 min keeps runaway-loop protection while letting heavy ops finish. **#2 Cancel upstream replica + flush KV on timeout** When the watcher gave up at the cap, the upstream Replicas workspace kept processing silently — burning credits indefinitely. The bridge had no visibility into what state the replica ended up in. On timeout we now: - DELETE /v1/replica/{id} so the workspace stops - Flush `room:{roomId}` / `replica:{id}` (or `chat:{id}:thread:{tid}` for TG) KV mappings so the next message in the room spawns fresh - Then setTerminal + deleteAll as before - Failed-frame message updated: "Send a new message to start a fresh session." so the user knows the room is recoverable Matches the behavior we already had on claude-result 404/410 paths. **Validation** - Matrix: 173/173 ✅ · typecheck clean · deployed `1d6a1f2d` - Telegram: 99/99 ✅ · typecheck clean · deployed `944a6aa3` Co-Authored-By: itsablabla <itsablabla@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
3 tasks
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.
Summary
Found via review of the Lark Admin room: last turn there hit the 30-min watch timeout while the agent was actively making progress through MCP config cleanups. Session has 317 cumulative steps / 40 turns — this is real heavy ops work, not a runaway loop.
#1 Bump MAX_WATCH_DURATION_MS 30 → 60 min (both bridges)
Lark Admin's
"Watch timed out — agent ran longer than 30 min"was a false-positive cap on legitimate work. 60 min keeps runaway-loop protection while letting heavy ops finish.#2 Cancel upstream replica + flush KV on timeout
When the watcher gave up at the cap, the upstream Replicas workspace kept processing silently — burning credits indefinitely. The bridge had no visibility into what state the replica ended up in.
On timeout now:
room:{roomId}/replica:{id}(orchat:{id}:thread:{tid}for TG) KV mappingsMatches behavior on claude-result 404/410 paths.
Validation
1d6a1f2d944a6aa3Test plan
/debug/verify-room/{room}shows no live watcher, KVroom:entry is gone, next message spawns freshWorkspace · Slack Thread