Skip to content

feat(agent): name the accepting replica on hosted run starts - #4500

Merged
kojiwakayama merged 1 commit into
mainfrom
feat/hosted-run-start-advertises-owner
Sep 16, 2026
Merged

kojiwakayama merged 1 commit into
mainfrom
feat/hosted-run-start-advertises-owner

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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-url so the caller can reach it again. The hosted default-chat start route (POST /api/runs) did not.

What changes

  • createHostedAgentServiceRouteSet accepts an optional resolveRuntimeOwnerInvokeUrl(request). It defaults to the existing resolver in src/internal-agents/runtime-owner.ts (VERYFRONT_RUNTIME_OWNER_HOST, POD_IP, or a network interface).
  • handleDurableChatRunExecuteRequest adds x-veryfront-runtime-owner-invoke-url when it accepts a start (202).
  • Nothing changes for any other response. A resolver that throws or returns nothing also leaves the accepted response as it was, since the run is accepted either way and control keeps using the shared address.

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

  • an accepted default-chat start names the replica that accepted it
  • a rejected start (401) names none
  • an accepted start is unaffected when the replica address cannot be resolved

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, every src/agent/service test suite, and docs:api-reference:check pass.

https://claude.ai/code/session_01NonPHDcbWsisd2GFB68ALo

Summary by CodeRabbit

  • New Features

    • Durable chat start responses can now include the runtime owner’s invocation URL when available.
  • Bug Fixes

    • Unauthenticated requests and cases where the runtime owner URL cannot be resolved no longer advertise a replica URL.
    • Chat starts continue returning a successful response even when runtime owner resolution fails.

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
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4b14e04e-662c-452f-ae5c-e21619441a2c

📥 Commits

Reviewing files that changed from the base of the PR and between 94e5463 and 265ab1f.

📒 Files selected for processing (2)
  • src/agent/service/routes.test.ts
  • src/agent/service/routes.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

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

Changes

Runtime-owner URL handling

Layer / File(s) Summary
Resolver option and test wiring
src/agent/service/routes.ts, src/agent/service/routes.test.ts
The route set adds an optional resolveRuntimeOwnerInvokeUrl callback. Tests wire the callback and default it to a null result.
Accepted-start response handling
src/agent/service/routes.ts, src/agent/service/routes.test.ts
A resolved URL is added to accepted 202 responses. Non-202 responses, null results, and resolver failures omit the header. Tests cover these cases.

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
Loading

Merge Risk: ⚪ Minimal · up to 265ab

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: advertising the accepting replica for hosted run starts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/hosted-run-start-advertises-owner

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 289 2307 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@gitar-bot

gitar-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 265ab1fda2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@kojiwakayama
kojiwakayama added this pull request to the merge queue Sep 16, 2026
Merged via the queue into main with commit 7c47cc6 Sep 16, 2026
67 checks passed
@kojiwakayama
kojiwakayama deleted the feat/hosted-run-start-advertises-owner branch September 16, 2026 13:40
@kojiwakayama kojiwakayama mentioned this pull request Sep 16, 2026
3 tasks
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