Agent Chain with Structured I/O

Sequential three-agent structured output mapping
24 nodes

/projects/agentworkflow

Agent Chain with Structured I/O

08

A Next.js AI SDK 6 demo where three ToolLoopAgents run in sequence: Research gathers sources, Expanded Research deepens the findings, and Synthesis turns the typed handoff into a final answer.

Project context05

Problem

Single-agent research demos often lose structure as soon as they scrape real sources. Findings become untyped text blobs, later stages cannot trust inputs, and the final synthesis has weak provenance.

Solution

Agent Chain with Structured I/O runs three sequential agents for discovery, expanded research, and synthesis. Each stage passes typed outputs forward through schemas and tool-specific evidence collection.

Challenges

The core challenge is preserving useful source detail while keeping handoffs compact and valid. Discovery, scraping, expansion, and synthesis each need different prompts, tools, and data contracts.

Innovation

The project demonstrates a practical pattern for agent pipelines: use models for judgment, tools for retrieval, and Zod schemas for stage boundaries so multi-step work remains inspectable.

Domain expertise

This highlights Stefan's skill in AI SDK workflows, structured generation, web research agents, Exa/Cheerio retrieval, schema-governed handoffs, and practical agent product prototyping.

Case study evidence11

Outcomes

  • Shows how multi-step research agents can preserve provenance and structure instead of collapsing into one long answer.
  • Makes stage handoffs inspectable enough for debugging, replay, and UI rendering.
  • Provides a compact reusable pattern for research products that need discovery, expansion, and synthesis.

Architecture decisions

  • Three agent stages keep discovery, expanded analysis, and final synthesis as separate responsibilities.
  • Zod output schemas define the exact payload each downstream stage can trust.
  • Exa and Cheerio retrieval tools separate evidence collection from model reasoning.

Domain expertise signals

Structured I/OResearch agentsTool callingSchema handoffsSource provenance
Technical deep dive09

Agent Chain with Structured I/O demonstrates the smallest useful pattern for serious agent workflows: separate stages, typed outputs, retrieval tools, and inspectable handoffs.

Stage boundaries

Discovery, expanded research, and synthesis are separate because each stage has a different job. This keeps the first agent from over-summarizing and gives later stages reliable structured inputs.

Retrieval strategy

Exa and Cheerio are used for evidence collection rather than letting the model hallucinate source context. Search, scrape, and crawl tools give each stage external grounding.

Schema governance

Zod contracts make handoffs explicit at runtime. That is critical because multi-agent chains fail silently when one stage returns prose where the next stage expects structured evidence.

Debuggability

Typed intermediate outputs make the workflow easier to inspect, replay, and render in a UI. The architecture favors practical product debugging over magical agent autonomy.

What this proves

  • Three-stage research workflow
  • Runtime-validated handoff schemas
  • Search and scrape tools separated from reasoning
  • Structured final synthesis instead of free-form accumulation
3agent stages
2tool families
7search/scrape tools
3Zod output schemas
60sroute cap
AI SDK 6structured I/O
Technology stack08
Next.js

Next.js

Pairs the visual workflow page with route handlers, so each agent stage can run server-side without a separate backend.

React

React

Keeps the canvas, stage status, traces, and final answer reactive as each agent finishes.

TypeScript

TypeScript

The workflow depends on typed handoffs, so compile-time structure helps prevent one stage from breaking the next.

AI SDK

AI SDK

Provides ToolLoopAgent, structured output, stop conditions, and streaming primitives in one agent-friendly API.

OpenAI

OpenAI

Used for reliable structured generation across the research, expansion, and synthesis agents.

Exa

Exa

Gives the research stages a high-signal discovery tool for web, Reddit, Wikipedia, and news sources.

Ch

Cheerio

Acts as the dependable scrape/crawl fallback when API-backed discovery is unavailable or too narrow.

Z

Zod

Makes every agent output a runtime-validated contract, which is what keeps the chain stable.

Tools implemented06

Research Agent 1

Collects sources, topics, and initial findings before any deeper analysis runs.

Expanded Research Agent 2

Receives the first typed packet and adds more detail, sources, analysis, and recommendations.

Synthesis Agent 3

Combines both prior structured outputs into a final answer with key points and next steps.

Exa discovery tools

Search web, Reddit, Wikipedia, and news so the first two agents can gather external evidence.

Cheerio scrape and crawl tools

Fetch and parse pages directly when search APIs do not provide enough page content.

Structured handoff schemas

Zod and Output.object force each stage to return the exact shape the next stage expects.

Stefan Creadore · @Eldergenixproduction agent systems mapped end to end