Skip to content

fix(bridges): 30→60 min watch cap + cancel upstream replica on timeout#33

Merged
replicas-connector[bot] merged 1 commit into
mainfrom
fix/timeout-bump-cancel-upstream
May 30, 2026
Merged

fix(bridges): 30→60 min watch cap + cancel upstream replica on timeout#33
replicas-connector[bot] merged 1 commit into
mainfrom
fix/timeout-bump-cancel-upstream

Conversation

@replicas-connector

Copy link
Copy Markdown
Contributor

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:

  • DELETE /v1/replica/{id} so the workspace stops
  • Flush room:{roomId} / replica:{id} (or chat:{id}:thread:{tid} for TG) KV mappings
  • Then setTerminal + deleteAll as before
  • Failed-frame message updated: "Send a new message to start a fresh session."

Matches behavior on claude-result 404/410 paths.

Validation

  • Matrix: 173/173 ✅ · typecheck clean · deployed 1d6a1f2d
  • Telegram: 99/99 ✅ · typecheck clean · deployed 944a6aa3

Test plan

  • Typecheck + tests + deploy
  • Smoke: kick off a 60+ min agent task, confirm it now runs to completion
  • After a timeout: confirm /debug/verify-room/{room} shows no live watcher, KV room: entry is gone, next message spawns fresh

Created by Jaden (jadengarza@pm.me) with Replicas
Workspace  ·  Slack Thread

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>
@capy-ai

capy-ai Bot commented May 30, 2026

Copy link
Copy Markdown
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.

@replicas-connector replicas-connector Bot merged commit a1ce0e7 into main May 30, 2026
1 of 3 checks passed
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.

0 participants