Skip to content

fix stale initial chat URL on agent switch - #2020

Draft
threepointone wants to merge 1 commit into
mainfrom
codex/fix-1864-stale-chat-url
Draft

fix stale initial chat URL on agent switch#2020
threepointone wants to merge 1 commit into
mainfrom
codex/fix-1864-stale-chat-url

Conversation

@threepointone

Copy link
Copy Markdown
Contributor

What changed

  • suppress useAgent().getHttpUrl() while a room change is still rendering against the previous PartySocket
  • defer initial-message loading until the socket matches the new logical Agent address
  • derive loader identity from the intended leaf address for ordinary room/sub-agent routing
  • preserve server-routed basePath behavior
  • add a browser/Worker regression that changes both the Agent name and auth query

Why

On an Agent name change, useAgentChat could key a new initial-message request under the new conversation while getHttpUrl() still returned the previous socket URL. That sent the previous auth token to the new logical request and cached the old conversation under the new key.

Fixes #1864.

Validation

  • regression reproduced before the production fix: the new logical address loaded through the old path/token
  • focused regression passes after the fix
  • Agents React project: 10 files, 124 tests passed
  • affected Agents and React-test TypeScript projects pass
  • repository export, formatting, and lint checks pass

The repo-wide check wrapper attempted to reinstall existing node_modules and was declined; its individual checks were run directly. The full typecheck wrapper could not resolve tsgo from its subprocess PATH, so the affected TypeScript projects were run directly and passed.

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 46dfa5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2020

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2020

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2020

create-think

npm i https://pkg.pr.new/create-think@2020

hono-agents

npm i https://pkg.pr.new/hono-agents@2020

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2020

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2020

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2020

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2020

commit: 46dfa5b

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.

useAgentChat: /get-messages fires with stale socket URL (and old auth token) when name prop changes

1 participant