MCPcopy
hub / github.com/CopilotKit/CopilotKit / onRunFinishedEvent

Function onRunFinishedEvent

packages/bot-telegram/src/event-renderer.ts:250–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248
249 // ── 4. Run lifecycle: finalise streams ─────────────────────────────
250 async onRunFinishedEvent() {
251 if (aborted) return;
252 const tasks: Promise<void>[] = [];
253 for (const [id, stream] of Array.from(streams.entries())) {
254 // Best-effort: a terminal-edit rejection (message too old, deleted,
255 // not-modified, flood-wait) must not bubble into the AG-UI run loop.
256 tasks.push(
257 stream
258 .finish()
259 .catch((e) =>
260 console.error("[bot-telegram] stream finalize failed:", e),
261 ),
262 );
263 streams.delete(id);
264 finalised.add(id);
265 }
266 buffers.clear();
267 await Promise.all(tasks);
268 // Drain any tool-status placeholders left over from a tool call whose
269 // END never arrived before the run finished — flip them to done so they
270 // aren't orphaned as a perpetual "🔧 using <tool>…".
271 await drainToolStatuses((tool) => `✅ ${tool}`);
272 },
273
274 // ── 5. Errors ─────────────────────────────────────────────────────
275 async onRunErrorEvent({ event }) {

Callers

nothing calls this directly

Calls 7

drainToolStatusesFunction · 0.85
entriesMethod · 0.80
pushMethod · 0.65
finishMethod · 0.65
errorMethod · 0.65
deleteMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…