AGENT SKILL

会话事件类型添加

add-event

添加从 LLM 会话流向客户端订阅者的新事件类型。涵盖从 ManagedSession 触发事件、持久化到 CMS,以及在 PilotSwarmSession.on() 中进行过滤。

License 许可
MIT
最近更新
2026-11-15
Stars
★ 16
Forks
10

01 前言 Front Matter

name
add-event
description
Add a new event type that flows from the LLM session through to client subscribers. Covers firing the event from ManagedSession, persisting to CMS, and filtering in PilotSwarmSession.on().

03 SKILL.md 正文

Add a New Event Type

Events flow from the Copilot SDK through ManagedSession, get persisted to CMS, and are delivered to client subscribers.

Steps

  1. Fire the event from ManagedSession in src/managed-session.ts:

    • Events are captured via the onEvent callback passed to runTurn().
    • Inside the copilotSession.on() handler, events are captured as CapturedEvent objects:
      const captured: CapturedEvent = {
          eventType: "my.event_type",
          data: eventData,
      };
      collectedEvents.push(captured);
      opts?.onEvent?.(captured);
      
  2. Persist to CMS — events are automatically persisted by the activity in src/session-proxy.ts via the onEvent callback, which calls catalog.recordEvents(). No changes needed unless you want special handling.

  3. Filter in PilotSwarmSession.on() — if the event needs special client-side filtering (e.g., excluding ephemeral events from persistence), add logic in src/client.ts:

    session.on("my.event_type", (event) => { ... });
    
  4. Add a test — verify the event appears in session.getMessages() and/or via session.on() polling.

Event naming conventions

  • Use dot-separated names: category.action (e.g., assistant.message, tool.execution_start).
  • Ephemeral events (like assistant.message_delta) should NOT be persisted to CMS — they are filtered out in session-proxy.ts.

Event flow

CopilotSession.on(event)           ← Copilot SDK fires event
  ↓
ManagedSession captures as CapturedEvent
  ↓
onEvent callback → session-proxy.ts → catalog.recordEvents()   ← persisted to CMS
  ↓
PilotSwarmSession.on() polls CMS → delivers to client subscribers

Key files

04 同仓库更多 Skills

microsoft
microsoft/PilotSwarm

workflow-testing

Load before you test a Workflow with mocked effects — the test, test_respond and test_advance operations, fixtures, interception ids, valid answers, the virtual clock, test evidence and what a test run does not prove.

★ 16
microsoft
microsoft/PilotSwarm

workflow-tools

Every argument of the Workflow tools, testing a revision, package definitions and the refusals you can fix. Load when a Workflow tool's short description is not enough.

★ 16
microsoft
microsoft/PilotSwarm

workflow-reference

Field reference for Workflow YAML (root keys, every state type, bindings, outputs, runtime error codes), what the engine guarantees, and a review fan-out example. For design, call load_skill with name workflow-authoring.

★ 16
microsoft
microsoft/PilotSwarm

workflow-patterns

Load when one Workflow must run different nodes in its branches at the same time (a different prompt or model for each branch), or loops back to a state (a polling loop). Named branches, the router pattern, examples that compile.

★ 16
microsoft
microsoft/PilotSwarm

workflow-authoring

Load before you create, edit, publish or run a Workflow (pilotswarm.dev/v1) — choosing states, bounded graphs, bindings, typed contracts, agent and parallel states, the lifecycle and failure diagnosis.

★ 16
microsoft
microsoft/PilotSwarm

tla-formal-validation

Required for any change to the core orchestrations (the durable session orchestration, session hydration and dehydration, and the Workflow controller and store). Teaches how to model the change in TLA+, update the existing models, run TLC with the repo runner, read the results, turn a counterexample into a fix and a regression test, and record the binding to the code.

★ 16