Skip to content

Send a run's tools, context and catalog once, then by their hashes - #2823

Merged
davidmckayv merged 1 commit into
mainfrom
waste/runreq-app
Dec 3, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
waste/runreq-app

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Every run the web app sent, and every join of a conversation, carried the same tools, context and generative UI catalog. For a Bot holding every component and its computer that is 146 KB, on every message and every step of a turn. Where the server answers runPartsByReference (#2819), the first request of a page now carries each part with its hash, and every request after it carries the hashes alone.

Measured with the real app, through its own CopilotKit provider and every tool and component it registers:

Request Before After
A run 146,378 B 913–1,088 B
A join of a conversation 146,502 B about 1 KB (the first of a page carries the parts once)

How it works:

  • On the request, not the run. The SDK checks each run against AG-UI's schema as it sends it, and the by-reference form is deliberately not one AG-UI accepts. So the run stays whole all the way through the SDK, and every subscriber and middleware on the page sees it whole. Only the request body changes, in the agent's own fetch. That fetch is wrapped however often the SDK sets it, because the SDK resets it whenever it registers the agent again. This covers both run paths: events back on the request, and events over the realtime socket.
  • When the server disagrees. A part the server no longer holds (409 RUN_PARTS_NEEDED) sends the request again once, carrying every part. Any other 409, such as a conversation that is already answering, goes back to the SDK unchanged.
  • Older servers. A server that refuses the form (400) is an older server behind a newer answer, as in a rolling upgrade. It gets that request whole, and every later one from the page. A server that doesn't advertise the form gets every request whole, as today.
  • Every Bot gets the whole run. The server puts each part back before the run goes anywhere. Built-in Bots and Bots connected over plain AG-UI receive exactly what they received before.

Where it runs

In the browser: app/src/lib/copilot/run-parts.ts, given to each agent beside its offer in bot-offer.ts. The server puts the parts back with fillRunParts from shared/run-parts.ts (#2819).

API and database

No API change here; it reads deployment.runPartsByReference. No database change.

Changelog

Web app and OpenBot Desktop.

  • Conversations. Sending a message, joining a conversation and every step of a Bot's turn now upload about 1 KB instead of about 145 KB, on servers that support it.

Proof

app/tests/run-parts-sent.test.tsx runs the real app against a server that fills the parts back with fillRunParts (the server's own code):

  • First request, then hashes. The first request carries every part, the run after it is under 5 KB, and what the server hands on is the whole run, byte for byte.
  • A part the server forgot. The run is sent again once, with every part and the same run id, and runs once.
  • A server that doesn't take the form. It gets every request whole.
  • An older server behind a newer answer. It refuses the form with 400; that request goes again whole, and so does every one after it.

Red before the fix: with sendPartsByReference not given, the first test fails (the run after the first is 146 KB). The whole app suite passes.

Every run and every join of a conversation the web app sent carried the
same tools, context and generative UI catalog: 146 KB for a Bot holding
every component and its computer, on every message and every step of a
turn. Where the server answers runPartsByReference, the first request of a
page now carries each part with its hash, and every request after it the
hashes alone: about 1 KB.

It is done on the agent's own fetch, not on the run, because the SDK checks
a run against AG-UI's schema as it sends it and the by-reference form is
deliberately not one AG-UI takes. So everything on the page, and every Bot
the server hands the run to, still sees the run whole.

A part the server no longer holds (409 RUN_PARTS_NEEDED) sends the request
again once with every part; any other 409 goes back to the SDK as before. A
server that refuses the form (400, an older one behind a newer answer) gets
that request and every later one whole. A server that doesn't say it takes
the form gets every request whole, as today.
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit ecbaaf2 Dec 3, 2026
27 checks passed
@davidmckayv
davidmckayv deleted the waste/runreq-app branch December 3, 2026 01:05
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