Skip to content

Resolve the MCP session name from a single source in the alarm path - #1801

Merged
RhysSullivan merged 1 commit into
mainfrom
fix/session-alarm-name-resolution
Aug 28, 2026
Merged

Resolve the MCP session name from a single source in the alarm path#1801
RhysSullivan merged 1 commit into
mainfrom
fix/session-alarm-name-resolution

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Problem

The MCP session Durable Object's alarm could die reading the session id it had
just decided existed.

PartyServer resolves a DO's name from three places, and does not consult them in
one place: the name getter reads ctx.id.name and an in-memory field that is
hydrated only during initialization, while the durable __ps_name record is
read only by that initialization. The alarm handler makes most of its
decisions itself and delegates to super.alarm() on one branch only, so it
never runs that hydration.

The alarm's unaddressable-session guard read the durable record directly. On an
invocation without a ctx.id.name it therefore concluded the session was
addressable, continued — and threw on the very next read of the session id,
which was there to put an id in a log line about the decision it had just
made. The lease branches log before they act, so the extension was lost with the
line: the alarm died, retried, and the session stayed pinned without making
progress.

Fix

One accessor now answers "what is this DO's name", consulting ctx.id.name, the
in-memory field, and the durable record, with a defined fallback order. The
alarm resolves the name through it up front and remembers the answer, so the
guard and every read after it agree by construction.

Separately, and independently of that ordering: a read of the session id for a
log line or a span attribute can no longer abort the work it is describing.
Observational reads go through a total accessor that falls back to a placeholder
instead of throwing. Callers that genuinely cannot proceed without an id —
execution-owner routing, approval URLs — still get the strict accessor and its
throw, because a wrong id is worse there than a failure.

An alarm that can resolve no name from any source now logs that and exits
cleanly after releasing the runtime and dropping the alarm, rather than throwing
into an endless retry.

Testing

  • packages/hosts/cloudflare/src/mcp/agent-session-durable-object.test.ts: four
    new cases over the existing ctx/storage harness — an alarm on a DO whose
    ctx.id.name is unset but whose durable record exists disposes the session
    the record names; the same shape extends a paused lease instead of dying on
    its log; an alarm with no name from any source completes and cleans up; an
    observational id read never throws. Full file: 23 passed.
  • Mutation check: reverting the observational accessor to the raw PartyServer
    getter fails all four new cases and leaves the pre-existing 19 passing.
  • packages/hosts/cloudflare MCP unit suites: 89 passed.
  • e2e cloud/mcp-session-cold-init.test.ts and
    cloud/mcp-destroyed-session-envelope.test.ts: both pass, before and after.
  • typecheck and lint green.

This is verified at the unit level by the declared exception for cases the dev
stack cannot produce: miniflare addresses every Durable Object by name, so an
alarm with an unset ctx.id.name cannot be provoked black-box.

The alarm guard read the durable name record while every later read went through PartyServer, which consults only ctx.id.name and an in-memory field the alarm path never populates. An alarm could pass the guard and then throw on a session id read for a log line. Route all reads through one accessor and make observational reads total.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud cadf6ba Aug 28 2026, 04:29 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing cadf6ba Commit Preview URL

Branch Preview URL
Aug 28 2026, 04:26 AM

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1801

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1801

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1801

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1801

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1801

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1801

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1801

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1801

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1801

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1801

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1801

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1801

executor

npm i https://pkg.pr.new/executor@1801

commit: cadf6ba

@RhysSullivan
RhysSullivan marked this pull request as ready for review August 28, 2026 04:40
@RhysSullivan
RhysSullivan merged commit d5946f1 into main Aug 28, 2026
44 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.

1 participant