Skip to content

examples: pass the machine to createAiSdkExecutors where setupAgent declares the models - #156

Merged
davidkpiano merged 1 commit into
nextfrom
examples-executors-from-machine
Oct 13, 2026
Merged

davidkpiano merged 1 commit into
nextfrom
examples-executors-from-machine

Conversation

@davidkpiano

@davidkpiano davidkpiano commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #155. createAiSdkExecutors(machine) reads models from the machine's setupAgent({ models }), so the examples no longer need to repeat the map.

Changed

59 example files plus three removed models imports (braintrust-evals/index.ts, braintrust-evals/seams.ts, email-drafter/index.ts, mastra-host/index.ts). Every rewritten site passed the exact models object its machine's setupAgent received; no behaviour change, no src/ or docs/ edits.

Deliberately left

  • examples/cloudflare-agent-host — builds its own models map per Durable Object from env bindings.
  • examples/crash-recovery — setupAgent declares no models; passes an inline map.
  • examples/json-agent — uses resolveModel.
  • examples/mock-model.ts — mock adapter with resolveModel + settings.
  • examples/next-host/agent-runtime.ts — the machine lives in app/api/agent/route.ts, which imports models from this file; importing the machine back would be circular.
  • examples/plain-xstate, examples/xstate-v5-json — plain setup / fromV5Config, no setupAgent models.
  • examples/tanstack-ai-stream/index.ts — wraps the map ({ writer: openaiText(models.writer) }); provider.test.ts builds adapters ad hoc.
  • demo/src/lib/agent-runner.ts, email-drafter-compare.ts, email-drafter-propose.ts — hosts own a map that differs from the setup's; machine-chat.server.ts uses resolveModel.

Verification

  • pnpm vitest --run examples src/examples.test.ts ✅
  • pnpm run typecheck ✅
  • pnpm run lint ✅ (pre-existing warnings in docs/snippet-globals.ts only)
  • pnpm run format:check ✅
  • pnpm run docs:check ✅

Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • AI-powered examples now configure their default executors using the same setup as the workflow they run, improving alignment between model configuration and execution.
    • Custom executors supplied by callers continue to be supported.

…eclares the models

Replaces createAiSdkExecutors({ models }) with createAiSdkExecutors(machine) at
every example and demo call site whose models map is the same one the machine's
setupAgent({ models }) received, and drops the three now-unused models imports.
Call sites that pass settings or resolveModel, wrap or subset the map, own a
different map than the setup, or build a machine without setupAgent models are
left as they were.
@changeset-bot

changeset-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0d5435e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9958010-6cea-4189-99d5-b1114792e34c
📥 Commits

Reviewing files that changed from the base of the PR and between 6928e0e and 0d5435e.

📒 Files selected for processing (62)
  • examples/adaptive-rag/index.ts
  • examples/agent-supervisor/index.ts
  • examples/agentic-rag/index.ts
  • examples/ai-sdk-evaluator-optimizer/index.ts
  • examples/ai-sdk-host/index.ts
  • examples/ai-sdk-ui-stream/index.ts
  • examples/answer-reuse/index.ts
  • examples/booking-compensation/index.ts
  • examples/braintrust-evals/index.ts
  • examples/braintrust-evals/seams.ts
  • examples/chameleon/index.ts
  • examples/chat-with-pdf/index.ts
  • examples/chatbot-simulation-eval/index.ts
  • examples/code-assistant/index.ts
  • examples/context-compaction/index.ts
  • examples/corrective-rag/index.ts
  • examples/customer-support/index.ts
  • examples/data-enrichment/index.ts
  • examples/deadline-escalation/index.ts
  • examples/deep-research/index.ts
  • examples/email-drafter/index.ts
  • examples/feynman-tutor/index.ts
  • examples/game-agent/index.ts
  • examples/game-loop-agent/index.ts
  • examples/generate-and-repair/index.ts
  • examples/guardrails/index.ts
  • examples/hierarchical-teams/index.ts
  • examples/human-in-the-loop/index.ts
  • examples/info-gathering/index.ts
  • examples/joke/index.ts
  • examples/just-one/index.ts
  • examples/llm-compiler/index.ts
  • examples/long-running-onboarding/index.ts
  • examples/long-term-memory/index.ts
  • examples/map-reduce/index.ts
  • examples/mastra-host/index.ts
  • examples/model-fallback/index.ts
  • examples/multi-agent-debate/index.ts
  • examples/parallel-streams/index.ts
  • examples/plan-and-execute/index.ts
  • examples/port-walkthrough/index.ts
  • examples/project-planner/index.ts
  • examples/prompt-chaining/index.ts
  • examples/reflection-writer/index.ts
  • examples/reflexion/index.ts
  • examples/retrofit/index.ts
  • examples/retrofit/step1.ts
  • examples/retrofit/step2.ts
  • examples/retrofit/step3.ts
  • examples/review-tool-calls/index.ts
  • examples/river-crossing/index.ts
  • examples/route-replanning/index.ts
  • examples/self-discover/index.ts
  • examples/sql-agent/index.ts
  • examples/storm-writer/index.ts
  • examples/swarm-handoff/index.ts
  • examples/tnt-llm/index.ts
  • examples/todo-nl/index.ts
  • examples/tool-retrieval/index.ts
  • examples/tree-of-thoughts/index.ts
  • examples/triage/index.ts
  • examples/twenty-questions/index.ts
 ________________________
< Tree-sitter is my GPS. >
 ------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@davidkpiano
davidkpiano merged commit b884c73 into next Oct 13, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant