feat(agent): name the accepting replica on hosted run starts - #4500
Conversation
A hosted agent service keeps a detached run's session in the memory of the replica that accepted the start, and run control only works there. Starts arrive through a load-balanced address, so a later cancel through the same address can reach a replica without the session. The hosted default-chat start now adds x-veryfront-runtime-owner-invoke-url when it accepts a run, as the project agent-stream route already does, so the caller can reach that replica. Claude-Session: https://claude.ai/code/session_01NonPHDcbWsisd2GFB68ALo
|
@codex review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe route set now resolves a runtime-owner URL for accepted durable-chat starts and returns it in a response header. Tests cover successful resolution, unauthenticated requests, and resolver failures. ChangesRuntime-owner URL handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Client
participant DurableChatRoute
participant RuntimeOwnerResolver
Client->>DurableChatRoute: POST /api/runs
DurableChatRoute->>RuntimeOwnerResolver: Resolve runtime-owner URL
RuntimeOwnerResolver-->>DurableChatRoute: URL or no URL
DurableChatRoute-->>Client: 202 response with optional runtime-owner header
Merge Risk: ⚪ Minimal · up to The accepted-start header behavior has no established merge-blocking risk in the supplied implementation context. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Client bundle boundary
A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|



Why
A hosted agent service keeps each detached run's session in the memory of the replica that accepted the start. Run control for that run (cancel, resume) only works on that replica. Starts usually arrive through a load-balanced address, so a later control request through the same address can land on a replica without the session and do nothing. With two replicas, a cancellation sent through the shared address missed its run in 2 of 5 cases.
The project agent-stream route already solves this: it names its replica in
x-veryfront-runtime-owner-invoke-urlso the caller can reach it again. The hosted default-chat start route (POST /api/runs) did not.What changes
createHostedAgentServiceRouteSetaccepts an optionalresolveRuntimeOwnerInvokeUrl(request). It defaults to the existing resolver insrc/internal-agents/runtime-owner.ts(VERYFRONT_RUNTIME_OWNER_HOST,POD_IP, or a network interface).handleDurableChatRunExecuteRequestaddsx-veryfront-runtime-owner-invoke-urlwhen it accepts a start (202).The advertised URL keeps the resolver's existing shape, the same value the agent-stream route sends. A caller uses its origin to reach the replica.
Tests
The route-set test factory defaults the resolver to
null, so existing tests do not depend on the host's network interfaces.deno check,deno fmt --check,deno lint, everysrc/agent/servicetest suite, anddocs:api-reference:checkpass.https://claude.ai/code/session_01NonPHDcbWsisd2GFB68ALo
Summary by CodeRabbit
New Features
Bug Fixes