A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().
This example builds a two-stage article pipeline using Vibes’ Graph API: an outline node followed by a writing node. The Graph class manages state transitions between BaseNode instances - each node receives the current state, does its work, and either transitions to the next node with next() or terminates with output().
What you’ll learn
Defining graph nodes with BaseNode
State transitions using the next() free function
Terminal output using the output() free function
Composing a Graph from nodes and running it
Prerequisites
Vibes installed (jsr:@vibesjs/sdk)
ANTHROPIC_API_KEY environment variable set
Always import next and output as free functions from @vibesjs/sdk. Do not call them as instance methods (e.g., prefixed with this.) - they are standalone functions, not methods on BaseNode, and calling them as such will throw at runtime.
import { Agent, BaseNode, Graph, next, output } from "jsr:@vibesjs/sdk";import { anthropic } from "npm:@ai-sdk/anthropic";// --- State type ---type PipelineState = { topic: string; outline?: string; article?: string;};// --- Agents ---const outlineAgent = new Agent({ model: anthropic("claude-haiku-4-5-20251001"), systemPrompt: "Create a concise 3-point outline for a short article. Return only the outline.",});const writeAgent = new Agent({ model: anthropic("claude-sonnet-4-6"), systemPrompt: "Write a short 3-paragraph article based on the outline provided.",});// --- Graph nodes ---class OutlineNode extends BaseNode<PipelineState, string> { readonly id = "outline"; async run(state: PipelineState) { const result = await outlineAgent.run(`Create an outline for: ${state.topic}`); // Transition to the "write" node with updated state return next<PipelineState, string>("write", { ...state, outline: result.output }); }}class WriteNode extends BaseNode<PipelineState, string> { readonly id = "write"; async run(state: PipelineState) { const result = await writeAgent.run( `Outline:\n${state.outline}\n\nWrite the article.` ); // Terminal - return the final article return output<PipelineState, string>(result.output); }}// --- Compose and run ---const graph = new Graph<PipelineState, string>([ new OutlineNode(), new WriteNode(),]);const article = await graph.run({ topic: "The future of AI agents" }, "outline");console.log(article);
Run it
deno run --allow-net --allow-env graph-workflow.ts
How it works
State type
PipelineState carries all data through the graph. Each node receives the full state and returns a new state (immutable - always spread with { ...state, field: value }).
next(nodeId, newState)
Transitions to the named node. The nodeId must match the id of another node in the graph. The newState becomes the input state for that node. You can call it with or without explicit type parameters:
// With explicit generics (recommended for type safety)return next<PipelineState, string>("write", newState);// Without generics (TypeScript infers the types)return next("write", newState);
output(value)
Terminates the graph and returns value as the final result. The type parameter string (second generic on BaseNode<TState, TOutput>) must match.
// With explicit genericsreturn output<PipelineState, string>(result.output);// Without generics (TypeScript infers from BaseNode type parameters)return output(result.output);
new Graph([nodes])
Pass all nodes as an array. The second argument to graph.run() is the ID of the starting node.
Next steps
Graph concept page - persistence with FileStatePersistence, toMermaid(), runIter()
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Vibes Agent SDK","description":"Pydantic AI patterns for TypeScript. Using Vercel AI SDK.","colors":{"primary":"#18181B","light":"#FFFFFF","dark":"#09090B"},"logo":{"light":"https://mintcdn.com/personal-b3af1c31/qvI9_ro7L0JRXWH9/logo/light.svg?fit=max\u0026auto=format\u0026n=qvI9_ro7L0JRXWH9\u0026q=85\u0026s=3810b9d4cf0db80f00425a70d0459b2e","dark":"https://mintcdn.com/personal-b3af1c31/qvI9_ro7L0JRXWH9/logo/dark.svg?fit=max\u0026auto=format\u0026n=qvI9_ro7L0JRXWH9\u0026q=85\u0026s=7f30dfaf9fa6a9820cff667dc879333c"},"favicon":"/favicon.svg","navbar":{"links":[{"href":"https://jsr.io/@vibesjs/sdk","label":"JSR"}],"primary":{"type":"button","label":"⭐ Star on GitHub","href":"https://github.com/a7ul/vibes"}},"search":{"prompt":"How can I help you build AI agents?"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"personal-b3af1c31","hasAudioNarration":false,"actualSubdomain":"personal-b3af1c31","customDomains":["vibes-sdk.a7ul.com"],"gitSource":{"type":"github","owner":"a7ul","repo":"vibes","deployBranch":"main","contentDirectory":"packages/sdk/docs","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6ae94a1ed69537c8ab71a184:success","clientVersion":"0.0.4205","searchFilterCounts":[{"language":"default","tag":"Concepts","count":19},{"language":"default","tag":"Examples","count":9},{"language":"default","tag":"Getting Started","count":6},{"language":"default","tag":"Integrations","count":6},{"language":"default","tag":"Community","count":5},{"language":"default","tag":"Meta","count":5},{"language":"default","tag":"Advanced","count":4}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","content":"/* cyrillic-ext */\n@font-face {\n font-family: 'Geist';\n font-style: normal;\n font-weight: 100 900;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/geist/v5/gyByhwUxId8gMEwRGFWfOw.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'Geist';\n font-style: normal;\n font-weight: 100 900;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/geist/v5/gyByhwUxId8gMEwYGFWfOw.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Geist';\n font-style: normal;\n font-weight: 100 900;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/geist/v5/gyByhwUxId8gMEwTGFWfOw.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Geist';\n font-style: normal;\n font-weight: 100 900;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/geist/v5/gyByhwUxId8gMEwSGFWfOw.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Geist';\n font-style: normal;\n font-weight: 100 900;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/geist/v5/gyByhwUxId8gMEwcGFU.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\nbody,html{font-family:'Geist', sans-serif!important}html:not(.dark) body,html:not(.dark) #__mintlify,html:not(.dark) main{background-color:#FAF8F4!important}a[data-active=\"true\"],[aria-current=\"page\"],[data-state=\"active\"]{background-color:rgba(0, 0, 0, 0.06)!important;color:#18181B!important}.dark a[data-active=\"true\"],.dark [aria-current=\"page\"],.dark [data-state=\"active\"]{background-color:rgba(255, 255, 255, 0.08)!important;color:#FFFFFF!important}"}],"page":{"pagePath":"examples/graph-workflow","slug":"/examples/graph-workflow","pageMetadata":{"title":"Graph Workflow","description":"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().","href":"/examples/graph-workflow","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`This example builds a two-stage article pipeline using Vibes’ Graph API: an outline node followed by a writing node. The `,_jsx(_components.code,{children:`Graph`}),` class manages state transitions between `,_jsx(_components.code,{children:`BaseNode`}),` instances - each node receives the current state, does its work, and either transitions to the next node with `,_jsx(_components.code,{children:`next()`}),` or terminates with `,_jsx(_components.code,{children:`output()`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`what-you’ll-learn`,children:`What you’ll learn`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Defining graph nodes with `,_jsx(_components.code,{children:`BaseNode`})]}),`\n`,_jsxs(_components.li,{children:[`State transitions using the `,_jsx(_components.code,{children:`next()`}),` free function`]}),`\n`,_jsxs(_components.li,{children:[`Terminal output using the `,_jsx(_components.code,{children:`output()`}),` free function`]}),`\n`,_jsxs(_components.li,{children:[`Composing a `,_jsx(_components.code,{children:`Graph`}),` from nodes and running it`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Vibes installed (`,_jsx(_components.code,{children:`jsr:@vibesjs/sdk`}),`)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`ANTHROPIC_API_KEY`}),` environment variable set`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Always import `,_jsx(_components.code,{children:`next`}),` and `,_jsx(_components.code,{children:`output`}),` as free functions from `,_jsx(_components.code,{children:`@vibesjs/sdk`}),`. Do `,_jsx(_components.strong,{children:`not`}),` call them as instance methods (e.g., prefixed with `,_jsx(_components.code,{children:`this.`}),`) - they are standalone functions, not methods on `,_jsx(_components.code,{children:`BaseNode`}),`, and calling them as such will throw at runtime.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`complete-example`,children:`Complete example`}),`\n`,_jsx(_components.p,{children:_jsxs(_components.em,{children:[`Source: `,_jsx(_components.a,{href:`https://github.com/a7ul/vibes/blob/main/packages/sdk/examples/graph-workflow.ts`,children:_jsx(_components.code,{children:`examples/graph-workflow.ts`})})]})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`52`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`52`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { Agent, BaseNode, Graph, next, output } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"jsr:@vibesjs/sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { anthropic } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"npm:@ai-sdk/anthropic\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// --- State type ---`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` PipelineState = {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` topic: string;`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` outline?: string;`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` article?: string;`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// --- Agents ---`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` outlineAgent = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model: anthropic(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"claude-haiku-4-5-20251001\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` systemPrompt: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Create a concise 3-point outline for a short article. Return only the outline.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` writeAgent = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model: anthropic(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"claude-sonnet-4-6\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` systemPrompt: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Write a short 3-paragraph article based on the outline provided.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// --- Graph nodes ---`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OutlineNode `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`extends`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` BaseNode\u003cPipelineState, string> {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` readonly`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"outline\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` run(state: PipelineState) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` outlineAgent.run(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`Create an outline for: ${state.topic}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Transition to the \"write\" node with updated state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` next\u003cPipelineState, string>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"write\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { ...state, outline: result.output });`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` WriteNode `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`extends`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` BaseNode\u003cPipelineState, string> {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` readonly`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"write\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` run(state: PipelineState) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` writeAgent.run(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Outline:\\\\n${state.outline}\\\\n\\\\nWrite the article.`\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Terminal - return the final article`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` output\u003cPipelineState, string>(result.output);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// --- Compose and run ---`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` graph = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Graph\u003cPipelineState, string>([`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OutlineNode(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` WriteNode(),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` article = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` graph.run({ topic: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The future of AI agents\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"outline\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`console.log(article);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`run-it`,children:`Run it`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`deno run --allow-net --allow-env graph-workflow.ts`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsx(Heading,{level:`3`,id:`state-type`,children:`State type`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`PipelineState`}),` carries all data through the graph. Each node receives the full state and returns a new state (immutable - always spread with `,_jsx(_components.code,{children:`{ ...state, field: value }`}),`).`]}),`\n`,_jsx(Heading,{level:`3`,id:`next-nodeid-newstate`,children:_jsx(_components.code,{children:`next(nodeId, newState)`})}),`\n`,_jsxs(_components.p,{children:[`Transitions to the named node. The `,_jsx(_components.code,{children:`nodeId`}),` must match the `,_jsx(_components.code,{children:`id`}),` of another node in the graph. The `,_jsx(_components.code,{children:`newState`}),` becomes the input state for that node. You can call it with or without explicit type parameters:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// With explicit generics (recommended for type safety)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` next\u003cPipelineState, string>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"write\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, newState);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Without generics (TypeScript infers the types)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` next(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"write\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, newState);`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`output-value`,children:_jsx(_components.code,{children:`output(value)`})}),`\n`,_jsxs(_components.p,{children:[`Terminates the graph and returns `,_jsx(_components.code,{children:`value`}),` as the final result. The type parameter `,_jsx(_components.code,{children:`string`}),` (second generic on `,_jsx(_components.code,{children:`BaseNode\u003cTState, TOutput>`}),`) must match.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// With explicit generics`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` output\u003cPipelineState, string>(result.output);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Without generics (TypeScript infers from BaseNode type parameters)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` output(result.output);`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`new-graph-nodes`,children:_jsx(_components.code,{children:`new Graph([nodes])`})}),`\n`,_jsxs(_components.p,{children:[`Pass all nodes as an array. The second argument to `,_jsx(_components.code,{children:`graph.run()`}),` is the ID of the starting node.`]}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next steps`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/concepts/graph`,children:`Graph concept page`}),` - persistence with FileStatePersistence, toMermaid(), runIter()`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Graph Workflow","description":"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().","href":"/examples/graph-workflow","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What you’ll learn","slug":"what-you’ll-learn","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Complete example","slug":"complete-example","depth":2,"children":[]},{"title":"Run it","slug":"run-it","depth":2,"children":[]},{"title":"How it works","slug":"how-it-works","depth":2,"children":[{"title":"State type","slug":"state-type","depth":3,"children":[]},{"title":"next(nodeId, newState)","slug":"next-nodeid-newstate","depth":3,"children":[]},{"title":"output(value)","slug":"output-value","depth":3,"children":[]},{"title":"new Graph([nodes])","slug":"new-graph-nodes","depth":3,"children":[]}]},{"title":"Next steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"personal-b3af1c31","siteName":"Vibes Agent SDK","title":"Graph Workflow - Vibes Agent SDK","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-03-15T23:53:53.959Z","originalFileLocation":"examples/graph-workflow.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\">\u003cmeta data-mint-head name=\"application-name\" content=\"Vibes Agent SDK\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Graph Workflow - Vibes Agent SDK\">\u003cmeta data-mint-head property=\"og:description\" content=\"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Vibes Agent SDK\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://vibes-sdk.a7ul.com/examples/graph-workflow\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://personal-b3af1c31.mintlify.site/_mintlify/api/og/v2?division=Examples\u0026amp;title=Graph+Workflow\u0026amp;description=A+multi-step+article+pipeline+using+Vibes+Graph+-+demonstrates+BaseNode%2C+state+transitions+with+next%28%29%2C+and+terminal+output%28%29.\u0026amp;theme=663cd623adeda12938867b43\u0026amp;signature=35d522320f8961c15e3c0ed56d3b8fd4d4faf658a7a729b4c3a2b7b270defacc\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Graph Workflow - Vibes Agent SDK\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://personal-b3af1c31.mintlify.site/_mintlify/api/og/v2?division=Examples\u0026amp;title=Graph+Workflow\u0026amp;description=A+multi-step+article+pipeline+using+Vibes+Graph+-+demonstrates+BaseNode%2C+state+transitions+with+next%28%29%2C+and+terminal+output%28%29.\u0026amp;theme=663cd623adeda12938867b43\u0026amp;signature=35d522320f8961c15e3c0ed56d3b8fd4d4faf658a7a729b4c3a2b7b270defacc\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/personal-b3af1c31/bA9_RFa3pHGAX5kg/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Vibes Agent SDK\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#18181B\">\u003clink data-mint-head rel=\"canonical\" href=\"https://vibes-sdk.a7ul.com/examples/graph-workflow\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/examples/graph-workflow.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://vibes-sdk.a7ul.com/#organization\",\"name\":\"Vibes Agent SDK\",\"url\":\"https://vibes-sdk.a7ul.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/personal-b3af1c31/qvI9_ro7L0JRXWH9/logo/light.svg?fit=max\u0026auto=format\u0026n=qvI9_ro7L0JRXWH9\u0026q=85\u0026s=3810b9d4cf0db80f00425a70d0459b2e\"}},{\"@type\":\"WebSite\",\"@id\":\"https://vibes-sdk.a7ul.com#website\",\"name\":\"Vibes Agent SDK\",\"url\":\"https://vibes-sdk.a7ul.com\",\"publisher\":{\"@id\":\"https://vibes-sdk.a7ul.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow#webpage\",\"url\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow\",\"name\":\"Graph Workflow\",\"description\":\"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\",\"dateModified\":\"2026-03-15T23:53:53.959Z\",\"isPartOf\":{\"@id\":\"https://vibes-sdk.a7ul.com#website\"},\"breadcrumb\":{\"@id\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Examples\",\"item\":\"https://vibes-sdk.a7ul.com/examples\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Graph Workflow\",\"item\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow#article\",\"headline\":\"Graph Workflow\",\"name\":\"Graph Workflow\",\"description\":\"A multi-step article pipeline using Vibes Graph - demonstrates BaseNode, state transitions with next(), and terminal output().\",\"url\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow\",\"mainEntityOfPage\":{\"@id\":\"https://vibes-sdk.a7ul.com/examples/graph-workflow#webpage\"},\"dateModified\":\"2026-03-15T23:53:53.959Z\",\"publisher\":{\"@id\":\"https://vibes-sdk.a7ul.com/#organization\"},\"isPartOf\":{\"@id\":\"https://vibes-sdk.a7ul.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Vibes Agent SDK\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Vibes Agent SDK\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/examples/graph-workflow.md","siteName":"Vibes Agent SDK","nav":{"global":null,"groups":[{"group":"Getting Started","pages":[{"title":"Vibes Agent SDK","href":"/index"},{"title":"Introduction","href":"/introduction"},{"title":"Installation","href":"/getting-started/install"},{"title":"Hello World","href":"/getting-started/hello-world"},{"title":"Troubleshooting","href":"/getting-started/troubleshooting"},{"title":"Getting Help","href":"/getting-started/getting-help"}]},{"group":"Concepts","pages":[{"title":"Agents","href":"/concepts/agents"},{"title":"Models","href":"/concepts/models"},{"title":"Dependencies","href":"/concepts/dependencies"},{"title":"Tools","href":"/concepts/tools"},{"title":"Toolsets","href":"/concepts/toolsets"},{"title":"Built-in Toolsets","href":"/concepts/built-in-tools"},{"title":"Tool Patterns","href":"/concepts/tool-patterns"},{"title":"Results","href":"/concepts/results"},{"title":"Messages and Chat History","href":"/concepts/messages"},{"title":"Streaming","href":"/concepts/streaming"},{"title":"Usage Limits","href":"/concepts/usage-limits"},{"title":"Human-in-the-Loop","href":"/concepts/human-in-the-loop"},{"title":"Testing","href":"/concepts/testing"},{"title":"Evaluation Framework","href":"/concepts/evals"},{"title":"Debugging and Monitoring","href":"/concepts/debugging"},{"title":"Multi-Agent Systems","href":"/concepts/multi-agent"},{"title":"Graph Workflows","href":"/concepts/graph"},{"title":"Graph Patterns","href":"/concepts/graph-patterns"},{"title":"Thinking / Extended Reasoning","href":"/concepts/thinking"}]},{"group":"Integrations","pages":[{"title":"MCP Client","href":"/integrations/mcp-client"},{"title":"MCP Server","href":"/integrations/mcp-server"},{"title":"AG-UI","href":"/integrations/ag-ui"},{"title":"A2A (Agent-to-Agent)","href":"/integrations/a2a"},{"title":"Temporal","href":"/integrations/temporal"},{"title":"Vercel AI UI","href":"/integrations/vercel-ai-ui"}]},{"group":"Community","pages":[{"title":"Community Toolsets","href":"/community/overview"},{"title":"TodoToolset","href":"/community/todo-toolset"},{"title":"SkillsToolset","href":"/community/skills-toolset"},{"title":"MemoryToolset","href":"/community/memory-toolset"},{"title":"Publishing Custom Toolsets","href":"/community/third-party-tools"}]},{"group":"Examples","pages":[{"title":"Examples","href":"/examples/index"},{"title":"Hello World","href":"/examples/hello-world"},{"title":"Weather Agent","href":"/examples/weather-agent"},{"title":"Chat App","href":"/examples/chat-app"},{"title":"Bank Support","href":"/examples/bank-support"},{"title":"RAG (Retrieval-Augmented Generation)","description":"Retrieval-augmented generation using a Vibes tool for vector search - swap the mock retriever for any real vector DB.","href":"/examples/rag"},{"title":"Graph Workflow","href":"/examples/graph-workflow"},{"title":"Human-in-the-Loop","description":"End-to-end deferred tool approval - the agent pauses when it needs to send an email, a human approves, and the agent resumes.","href":"/examples/human-in-the-loop"},{"title":"A2A (Agent-to-Agent)","href":"/examples/a2a"}]},{"group":"Advanced","pages":[{"title":"Multimodal","href":"/advanced/multimodal"},{"title":"Error Handling","href":"/advanced/error-handling"},{"title":"HTTP Retries","href":"/advanced/http-retries"},{"title":"Direct Model Requests","href":"/advanced/direct-model-requests"}]},{"group":"Meta","pages":[{"title":"Agent Skill","href":"/meta/agent-skill"},{"title":"Auto-Updates from Pydantic AI","href":"/meta/auto-updates"},{"title":"Acknowledgments","href":"/meta/acknowledgments"},{"title":"Contributing","href":"/meta/contributing"},{"title":"Feature Parity","href":"/reference/features"}]}]},"basePath":"","title":"Graph Workflow - Vibes Agent SDK","deploymentId":"dpl_FZMKUpaaKiVETbfqhoUe4sPFDTmY","buildId":"dpl_FZMKUpaaKiVETbfqhoUe4sPFDTmY","dynamics":[],"chunks":[]}