AgentSkillsCN

spoon-graph-development

将SpoonOS智能体部署至消息平台与API接口。当您需要将智能体集成至Telegram、Discord、Slack、REST API、Webhook,或定时任务时,可使用此功能。

SKILL.md
--- frontmatter
name: spoon-graph-development
description: Build StateGraph workflows with SpoonOS. Use when creating multi-step workflows, conditional routing, parallel execution, checkpointing, or multi-agent orchestration.

Graph Development

Build workflow graphs using SpoonOS StateGraph.

Quick Start

python
from spoon_ai.graph import StateGraph, END
from typing import TypedDict

class MyState(TypedDict):
    counter: int
    result: str

async def process(state: MyState) -> dict:
    return {"counter": state["counter"] + 1}

graph = StateGraph(MyState)
graph.add_node("process", process)
graph.set_entry_point("process")
graph.add_edge("process", END)

app = graph.compile()
result = await app.invoke({"counter": 0, "result": ""})

Scripts

ScriptPurpose
basic_graph.pySimple linear workflow
conditional_graph.pyConditional routing
parallel_graph.pyParallel node execution
checkpoint_graph.pyState persistence

References

ReferenceContent
patterns.mdCommon graph patterns
parallel.mdParallel execution modes

Node Types

  • Function nodes: async def node(state) -> dict
  • Agent nodes: SpoonReactMCP instances
  • Subgraph nodes: Nested StateGraph

Edge Types

  • Direct: graph.add_edge("a", "b")
  • Conditional: graph.add_conditional_edges("a", router, {...})

Best Practices

  1. Use TypedDict for state schemas
  2. Return only changed fields from nodes
  3. Use checkpointing for long workflows
  4. Implement timeout for external calls