brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
graph-runtimeBuild, compile, invoke, stream, debug, interrupt, and route custom LangGraph StateGraph/Pregel workflows.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this sub-skill when an agent needs to implement or repair custom LangGraph runtime logic: StateGraph construction, node wiring, conditional routing, reducers, compiled graph invocation, streaming, debug output, interrupts, resume commands, subgraphs, and low-level Pregel channel execution concerns.
StateGraph or compiled graph instead of using a prebuilt agent.typing_extensions.Annotated so concurrent node updates merge safely.interrupt() and resume with Command(resume=...).Command(goto=...), Send(...), add_conditional_edges(...), or set_conditional_entry_point(...).For prebuilt create_react_agent workflows, route to prebuilt-agents. For checkpoint saver choices, persistent stores, thread history, and production durability, route to persistence. For server deployment and config files, route to cli-deployment. For REST/SDK calls against a deployed graph, route to sdk-clients.
TypedDict, dataclass, or Pydantic model.Annotated[field_type, reducer] on state fields that multiple nodes may update in one step.StateGraph(state_schema, context_schema=None, input_schema=None, output_schema=None) builder.add_node(name, callable) or add_sequence([...]).add_edge(START, node), add_edge(node, END), set_entry_point(node), or set_finish_point(node).add_conditional_edges(source, route_fn, path_map=...) when the next node depends on state.compile(...) before invoke, stream, ainvoke, or astream; the builder itself is not executable.python skills/langgraph/sub-skills/graph-runtime/scripts/smoke_state_graph.py.Minimal example:
from typing_extensions import TypedDict
from langgraph.graph import END, START, StateGraph
class State(TypedDict):
value: int
def inc(state: State) -> State:
return {"value": state["value"] + 1}
builder = StateGraph(State)
builder.add_node("inc", inc)
builder.add_edge(START, "inc")
builder.add_edge("inc", END)
graph = builder.compile()
assert graph.invoke({"value": 1}) == {"value": 2}
StateGraph(...): graph builder for shared-state node workflows; accepts context_schema, input_schema, and output_schema.add_node(...): adds a callable or runnable; node names must be unique and cannot be START or END.add_edge(start, end): adds fixed routing; list starts wait for all named nodes before the target runs.add_conditional_edges(source, path, path_map=None): routes after a node based on a callable result.set_entry_point(node) and set_finish_point(node): convenience wrappers for START and END edges.add_sequence(nodes): creates a linear chain from callables or (name, callable) pairs.set_node_defaults(...): applies default retry, cache, timeout, or error-handler policies at compile time.compile(checkpointer=None, cache=None, store=None, interrupt_before=None, interrupt_after=None, debug=False, name=None): returns the executable compiled graph.See API Reference for parameter details, deprecations, and output shapes.
graph.invoke(input, config=None, *, context=None, stream_mode="values", interrupt_before=None, interrupt_after=None, durability=None) for sync final output.await graph.ainvoke(...) when any node or surrounding application is async.graph.stream(input, stream_mode="updates") or async for chunk in graph.astream(...) for stepwise output.values, updates, messages, custom, checkpoints, tasks, and debug.stream_mode=["updates", "values"] yields mode-tagged chunks.print_mode only for console debugging; it does not change returned data.subgraphs=True when you need child graph events included with namespace paths.version="v2" for typed stream parts from stream/astream; use stream_events(..., version="v3") when working with event transformers.See Workflows for reducer, conditional routing, interrupt/resume, subgraph, low-level Pregel, and streaming recipes.
config={"configurable": {"thread_id": "unique-run-id"}}.interrupt(value) to pause and surface a resumable request.graph.invoke(Command(resume=value), config) or stream the same command.interrupt_before=["node"] or interrupt_after=["node"] at compile or call time to pause around known nodes.Checkpoint and thread management belongs in persistence, but this sub-skill covers how runtime code calls interrupts and commands.
invoke is missing, confirm you called compile() and are not executing the builder.START or call set_entry_point.Annotated or ensure only one update reaches that key per step.path_map or annotate the routing function return type with Literal[...].thread_id and pass Command(resume=...) as the input.ainvoke/astream and avoid blocking sync work in async nodes.stream_mode, whether a list of modes was supplied, whether subgraphs=True is enabled, and whether version="v2" is enabled.Pregel validation fails, verify every input_channels, output_channels, and stream_channels entry exists and at least one input channel is subscribed by a node.See Troubleshooting for error patterns and fixes.
Run:
python skills/langgraph/sub-skills/graph-runtime/scripts/smoke_state_graph.py --help
python skills/langgraph/sub-skills/graph-runtime/scripts/smoke_state_graph.py
python skills/langgraph/sub-skills/graph-runtime/scripts/smoke_state_graph.py --start 3 --limit 5 --json
Expected default result includes a final state with value equal to 3 and a history showing routed node execution.
This guidance is distilled from LangGraph state graph source, runtime types, Pregel execution APIs, runtime tests for state, interruption, Pregel behavior, and stream events, plus public README claims about LangGraph as a durable stateful orchestration framework.
Runtime content intentionally excludes maintainer CI, release tooling, benchmark-only flows, expensive notebooks, and original checkout dependencies. The subgraph notebook evidence was only a moved-document pointer, so subgraph guidance here is based on runtime source/tests rather than a bundled notebook adaptation.