Repository navigation
examples: pass the machine to createAiSdkExecutors where setupAgent declares the models - #156
Conversation
…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.
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (62)
✨ Finishing Touches
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. Comment |
Follow-up to #155.
createAiSdkExecutors(machine)readsmodelsfrom the machine'ssetupAgent({ models }), so the examples no longer need to repeat the map.Changed
59 example files plus three removed
modelsimports (braintrust-evals/index.ts,braintrust-evals/seams.ts,email-drafter/index.ts,mastra-host/index.ts). Every rewritten site passed the exactmodelsobject its machine'ssetupAgentreceived; no behaviour change, nosrc/ordocs/edits.Deliberately left
examples/cloudflare-agent-host— builds its own models map per Durable Object from env bindings.examples/crash-recovery—setupAgentdeclares no models; passes an inline map.examples/json-agent— usesresolveModel.examples/mock-model.ts— mock adapter withresolveModel+settings.examples/next-host/agent-runtime.ts— the machine lives inapp/api/agent/route.ts, which importsmodelsfrom this file; importing the machine back would be circular.examples/plain-xstate,examples/xstate-v5-json— plainsetup/fromV5Config, nosetupAgentmodels.examples/tanstack-ai-stream/index.ts— wraps the map ({ writer: openaiText(models.writer) });provider.test.tsbuilds 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.tsusesresolveModel.Verification
pnpm vitest --run examples src/examples.test.ts✅pnpm run typecheck✅pnpm run lint✅ (pre-existing warnings indocs/snippet-globals.tsonly)pnpm run format:check✅pnpm run docs:check✅Summary by CodeRabbit