You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Durable CopilotKit AgentRunner on B4 storage: full event replay and live-run rejoin #928
CopilotKit's connect replays an in-memory runner (InMemoryAgentRunner: 1000 threads, 100 runs per thread, process-local). A Next restart, eviction, serverless or a second instance loses the thread, and the activity kit (@b4run/ag-ui/react + ./copilotkit) then renders nothing for a restored thread. CopilotKit documents AgentRunner (run/connect/isRunning/stop) as pluggable and explicitly invites "a custom runner backed by shared storage (Redis, PostgreSQL, etc.)"; the only first-party options are the single-instance @copilotkit/sqlite-runner and the hosted Intelligence tier. No OSS multi-instance runner exists (research: docs/superpowers/notes/2026-10-04-activity-restore-and-ecosystem-research.md, Part 2 §2 and §5 row A).
What
A @b4run/copilotkit-runner package implementing CopilotKit's AgentRunner over @b4run/sqlite-storage / @b4run/postgres-storage:
append every outbound AG-UI event per (threadId, runId);
connect() replays RUN_STARTED (marked as replay in metadata), MESSAGES_SNAPSHOT, the stored CUSTOM b4.step / STEP_* / SUBAGENT_* / ACTIVITY_* events, and the terminal RUN_FINISHED keeping outcome: interrupt so pendingInterrupts restores;
tail a run still streaming (live rejoin), handle connect-before-run, and prune by retention like the tool-call records.
Advantage
First OSS multi-instance runner, and the only one that restores a step/subagent/approval view losslessly. Depends on the storage decisions in the 2b restore spec (stamps and GET /threads/:id/turns), which may let the runner serve connect from the checkpoint instead of a separate event log.
Activity