Skip to content

Keep chat status updates going after the starting request ends - #180

Merged
tim-smart merged 1 commit into
mainfrom
agent/bob/fe35ae964505
Nov 6, 2026
Merged

tim-smart merged 1 commit into
mainfrom
agent/bob/fe35ae964505

Conversation

@tim-smart

Copy link
Copy Markdown
Contributor

Chat status messages stopped moving past "Starting" after #179.

#179 also moved the effect snapshot forward on eff-698-cloudflare-cluster. In that snapshot the Cloudflare entity runtime runs handlers through RpcServer, and RpcServer gives each request its own Scope, closed when the handler returns. Before, handlers saw the entity's scope. Alchemy's Postgres layer keeps one pool per Scope in context, and an effect/Pool whose scope is closed answers every get with an interrupt.

The session entity forks a turn into entityScope from the Receive handler, but the forked fiber still carried that request's Scope. Once Receive returned, every Postgres query from the turn was interrupted. The status watcher reads the kill switch on each tick. ChatKillSwitch.get catches failures but not interrupts, so the first tick killed the watcher and the status stayed at "Starting". saveIndex logged and went on, which is why production's chat_sessions rows still say running for turns that have replied.

This adds forkInEntity in Chat/Session.ts: it forks into the entity scope and also provides that scope as the fiber's Scope, as handlers had before. It replaces all four forkIn(..., entityScope) calls.

The new test in Session.test.ts uses a kill switch that interrupts once the caller's scope is closed, the way the production pool does. It fails without the fix ("Timed out waiting for a Working status") and passes with it.

PullRequestReview/RunEntity.ts also forks into its entity scope. I haven't checked whether any of that work queries Postgres after its request ends.

Closes EFF-3451

@tim-smart
tim-smart merged commit 67bf8e6 into main Nov 6, 2026
4 checks passed
@tim-smart
tim-smart deleted the agent/bob/fe35ae964505 branch November 6, 2026 13:24
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