feat(cloud-task): Durable run streaming through agent-proxy#2519
Conversation
What T-Rex did
ArtifactsFocused proxy stream edge-case test output
URL parsing proof for unencoded proxy run IDs
Generated focused proxy stream edge-case tests
Vitest output: 1 failed (URL encoding bug), 2 passed, 1 unhandled rejection (bootstrap race)
Generated proxy-stream-edge-cases TypeScript tests
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
apps/code/src/main/services/cloud-task/service.ts:654-658
**Encode proxy run IDs**
The proxy stream path inserts `watcher.runId` directly into the URL. If a run ID contains URL-special characters such as `/`, `?`, or `&`, `new URL()` treats those characters as path or query delimiters and the request goes to the wrong proxy route. The ingest side already encodes `runId`, so the read side should do the same.
```suggestion
const url = new URL(
usingProxy
? `${base}/v1/runs/${encodeURIComponent(watcher.runId)}/stream`
: `${base}/api/projects/${watcher.teamId}/tasks/${watcher.taskId}/runs/${watcher.runId}/stream/`,
);
```
### Issue 2 of 2
apps/code/src/main/services/cloud-task/service.ts:1188-1191
**Preserve bootstrap snapshot**
When `stream-end` arrives while bootstrap is still fetching historical logs, this branch stops and deletes the watcher before the bootstrap path can emit its snapshot. The pending `bootstrapWatcher()` then sees that the watcher is gone and returns, so subscribers never receive the existing run history. The `streamEnded && isBootstrapping` case needs to defer stopping until after bootstrap finishes.
Reviews (1): Last reviewed commit: "Implement agent proxy" | Re-trigger Greptile |
3d4147e to
10228ed
Compare
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
What T-Rex did
Artifacts
Verbose vitest output showing both failing repro tests with stack traces
trex-bugs.test.ts repro source
Reviews (2): Last reviewed commit: "Implement agent proxy" | Re-trigger Greptile |
8857d90 to
6256faa
Compare
b2e3c49 to
486fa1c
Compare
486fa1c to
f81975b
Compare
f81975b to
6acb50f
Compare
6acb50f to
fbdbdc5
Compare
992ed58 to
c0bc48a
Compare
|
Reviews (3): Last reviewed commit: "log ingest recovery at info not warn" | Re-trigger Greptile |
8c88ef2 to
ac854e3
Compare
ac854e3 to
1cbc344
Compare

Problem
Moves event streaming to agent-proxy
Changes
How did you test this?
Manually
Automatic notifications