Skip to content

fix(web): throttle useAgent re-renders (fixes UI freeze) + tool-call cards#363

Open
blove wants to merge 2 commits into
mainfrom
blove/research-tool-cards
Open

fix(web): throttle useAgent re-renders (fixes UI freeze) + tool-call cards#363
blove wants to merge 2 commits into
mainfrom
blove/research-tool-cards

Conversation

@blove

@blove blove commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The bug (found while adding tool cards)

A full research run froze the web UI — the renderer became unresponsive and never recovered. Root cause, from CopilotKit's own types:

throttleMs — "Throttle interval for re-renders triggered by onMessagesChanged/onStateChanged. Useful to reduce re-render frequency during high-frequency streaming updates." … "@default undefined (components/hooks without an explicit throttleMs will be unthrottled)"

Every useAgent() consumer — PlanPanel, SubagentActivity, MemoryCandidates, plus the CopilotSidebar transcript — re-rendered on every streamed token. A full research run streams hundreds of events (coordinator tokens + ~200 subagent events), so the main thread got pegged.

This is a pre-existing bug in the merged research web (#345), not caused by the cards. Fix: defaultThrottleMs={100} on <CopilotKit> (~10 re-renders/sec, still live-feeling). Applied to both demos — the chat UI has the identical latent issue.

Tool-call cards (the original feature)

A wildcard useRenderTool({ name: "*" }) card in the research UI showing each tool's name, status, argument, and output. It unwraps two layers of noise:

  • Dawn delivers args as a JSON string under input → cards showed {"input":"{\"path\":\"…\"}"}. Now: corpus/retrieval-augmented-generation.md.
  • Results arrive as a serialized LangChain ToolMessage → cards dumped {"lc":1,"type":"constructor",…}. Now: the actual content.

Test plan

Verified live in Chrome against a real model (research demo, full run):

  • Before: screenshot/CDP timed out 3× mid-run (renderer frozen).
  • After: UI stayed responsive for the entire run — plan reached 4/4, two researcher subagent dispatches streamed, cards rendered cleanly (recall(no memories found), searchCorpusRAG, readDoccorpus/retrieval-augmented-generation.md + real content).
  • typecheck + build green for @dawn-example/research-web and @dawn-example/chat-web.

🤖 Generated with Claude Code

blove and others added 2 commits July 13, 2026 15:05
The research UI froze during a full run: useAgent re-renders are UNTHROTTLED by
default (CopilotKit's documented default), so every panel and the sidebar
transcript re-rendered on every streamed token — hundreds per run — pegging the
renderer. Set defaultThrottleMs={100} on <CopilotKit> in both demos.

Also adds a wildcard tool-call card (useRenderTool name:'*') to the research UI,
unwrapping Dawn's JSON-string args and the serialized LangChain ToolMessage so
cards show the real argument and output instead of double-encoded internals.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dawnai Ready Ready Preview, Comment Jul 16, 2026 9:43pm

Request Review

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