Skip to content

Agent tools: R3-identity (draft): a child's run is its chat turn's run - #3346

Closed
mattzcarey wants to merge 38 commits into
slim/chat-fn-6s1from
slim/agent-runs-r3
Closed

mattzcarey wants to merge 38 commits into
slim/chat-fn-6s1from
slim/agent-runs-r3

Conversation

@mattzcarey

Copy link
Copy Markdown
Member

Draft of R3-identity, the last R step (CLOSEOUT 1b): the parts that do not depend on limits' 6f switch. Do not merge; it grows into R3-identity once the switch lands.

R3-identity makes a child's agent-tool run its chat turn's run on the new core (chatTurnDefinition, run id = request id, one stream per run across attempts) and deletes the child's own run store. What this draft has now:

  • The upgrade test for the rows a released version kept, Think (cf_agent_tool_child_runs, cf_agent_tool_milestones, think 0.24's exact DDL) and AIChatAgent (cf_ai_chat_agent_tool_runs, cf_ai_chat_agent_tool_milestones, ai-chat 0.12.3's): a completed run with output and a milestone, an error, an abort. After the carry-forward each inspects as it did, and the released tables are gone. On main the inspections already match and the tables stay, so the test is it.fails (it fails today for exactly that); R3-identity turns it into it. The open-row case (a turn being recovered at the upgrade) belongs with the switch's upgrade step and is added then.

What R3-identity will delete (line counts on main 751cad2):

  • packages/agents/src/chat/agent-tool-run-store.ts (500) and its four tables, released rows carried forward;
  • in chat/agent-tool-runs.ts (1,179): AgentToolRunsHost (44), rebind (12), isRecoveredRunCancelled (4), admitRecoveredTurn (18), reconcileStale (42), #recoveryOf and the chat-recovery incident read (44), reconcileOwn (10), isStale (3), plus the store calls throughout; what stays is inspect, chunks, tail, progress and the frame observer as functions;
  • the AgentToolBroadcastHooks type in chat/agent-tools.ts (37; the observer stays, taking its maps as arguments);
  • the host wiring in Think and AIChatAgent (createAgentToolRunStore, the rebind and admitRecoveredTurn calls, reconcileAgentToolChildRuns).

packages/agents/src/index.ts: 4,101 lines on main; R3-identity does not add to it, and its target at the end of R is at or below 4,100.

Tests here: the two upgrade tests, which pass as expected failures. No changeset.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f5e1dd5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: f5e1dd5

@agent-think

agent-think Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (dedbb588 → f5e1dd55, workflow run)

…ut messages, cancel-continuation, one continuation per batch, the leaf read first)
…swer starts no turn, and is dropped once its socket closed (rv-1)
… a tool answer's continuation extends the reply that holds the call (Devin on #3298)
… live answer's continuation names its reply, once per batch; a stopped waiting request keeps its question; injected answers pass the chunk hook (Devin)
…a client tool call does not hold the stall watchdog off (rv-6, rv-5)
… request to continue is kept for its batch (rv-1)
… chunk keeps the capability's chunk limit; a held stopped question survives a reset; continue requests are cleared at a turn's end (rv-1, Devin)
…arked on its run, and stores its question when reached (replaces the held list); a stop drops remembered continue requests; a denial answers a call (rv-1, Devin)
…drops only the stopped turn's continue request; a stopped queued turn settles aborted (rv-1)
…a reset while a server tool runs keeps the call (verify F18)
…ed; progress outputs are not flushed one by one (Devin)
… as the hosts' reply streams do, so a short reply cut off is kept (rv-1, harness-think)
…le it is quiet keeps what it sent (harness-think's eviction tests)
… replaced request is told it was skipped; tests for drop, merge, debounce and a regenerate under drop (rv-3)
…t, an empty reply answered again, stored or pinned body, a signal) (rv-6)
…d (ChatDeps.kv, the recent-terminals record; arch ruling)
…all carries the run's checkpoint, cancelTurn takes a reason (agent-runs' R3 needs)
…ent; ChatDeps.webSockets needs only getConnections
…inition and routes chat frames through chatDispatch (34 ai-chat test files fail; next: connect, public methods, the seam, deletions)
@mattzcarey
mattzcarey changed the base branch from main to slim/chat-fn-6s1 November 27, 2026 03:07
…he chat's lane and transcript; the test worker's queue and idle reads follow
…he tab that sent it, at once on a stop; queued message ids come from the waiting runs
…nt-tool child rows (expected to fail until R3-identity)
… run's metadata; tests on the chat-turn fixture
@mattzcarey

Copy link
Copy Markdown
Member Author

Closed while too much is in flight; not next (it waits on the seam in #3361). The branch slim/agent-runs-r3 stays and the PR reopens when S1 lands.

@mattzcarey mattzcarey closed this Nov 27, 2026
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