AGENT SKILL

add-activity

Add a new duroxide activity to the runtime. Activities are the durable boundary between the orchestration and session management — they dispatch to ManagedSession or SessionManager methods.

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

01 前言 Front Matter

name
add-activity
description
Add a new duroxide activity to the runtime. Activities are the durable boundary between the orchestration and session management — they dispatch to ManagedSession or SessionManager methods.

03 SKILL.md 正文

Add a New Activity

Activities are the durable boundary between the orchestration generator and the session layer. They must only accept and return serializable data.

Steps

  1. Define the activity function in src/session-proxy.ts inside registerActivities():

    runtime.registerActivity("myActivity", async (ctx: any, input: any) => {
        const { sessionId, ...args } = input;
        const session = await sessionManager.getOrCreate(sessionId, args.config);
        const result = await session.myMethod(args);
        return result;
    });
    
  2. Create a proxy function in createSessionProxy() (session-scoped) or createSessionManagerProxy() (manager-scoped):

    myActivity: (args: any) => {
        return ctx.scheduleActivityOnSession(
            "myActivity",
            { sessionId, ...args },
            affinityKey,
        );
    }
    
  3. Call it from the orchestration in src/orchestration.ts:

    const result = yield session.myActivity(args);
    
  4. Add tests in test/sdk.test.js.

Key constraints

  • Activities must only accept and return serializable data (no functions, no class instances).
  • Activity functions should be thin — delegate business logic to ManagedSession or SessionManager.
  • Use ctx.scheduleActivityOnSession() (not ctx.scheduleActivity()) to maintain session affinity.
  • The affinityKey ensures the activity runs on the same worker that holds the in-memory session.

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