From 3d069d4d4b0f97b76160b383a0ff1d5c54009680 Mon Sep 17 00:00:00 2001 From: itelo Date: Tue, 11 Aug 2026 15:43:45 -0300 Subject: [PATCH] perf(integrate): choose the embedded agent's model per mode (Opus / Haiku), budget $10 The embedded integration agent ran on one model with a $5 per-run cap; a full Customer Portal integration exhausted the Seam-hosted inference budget mid-run. Pick the model by the chosen mode instead: the customer-portal path is a small, high-value surface (embedded portal, reservation deep-links) and runs on Opus 4.8; the broader full-API path runs on cheap Haiku 4.5. Raise maxBudgetUsd to $10. Pairs with seamapi/seam-connect#17059 (proxy monthly cap -> $10; meter is a per-model price map so each path is priced by the model that actually ran). --- src/lib/steps/integrate.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/lib/steps/integrate.ts b/src/lib/steps/integrate.ts index 5387e49..ed485ab 100644 --- a/src/lib/steps/integrate.ts +++ b/src/lib/steps/integrate.ts @@ -61,12 +61,13 @@ export async function runIntegration(args: RunIntegrationArgs): Promise { prompt: goal, options: { cwd: root, - // Cost-tuned for a starter integration (Seam pays for this): Sonnet 5 is - // near-Opus on coding at ~half the token price, medium effort trims the - // thinking spend, and maxBudgetUsd is a hard per-run dollar ceiling. - model: 'claude-sonnet-5', + // Model depends on the chosen mode (see modelForMode): the customer-portal + // path is a small, high-value surface, so it runs on Opus 4.8; the broader + // full-API path runs on cheap Haiku 4.5. medium effort trims the thinking + // spend, and maxBudgetUsd is a hard per-run dollar ceiling. + model: modelForMode(mode), effort: 'medium', - maxBudgetUsd: 5, + maxBudgetUsd: 10, env: buildAgentEnv(inference), allowedTools: ALLOWED_TOOLS, // Auto-apply file edits so the agent runs uninterrupted; the developer @@ -128,6 +129,16 @@ export async function runIntegration(args: RunIntegrationArgs): Promise { } } +// The embedded agent's model depends on the mode the developer chose. The +// customer-portal integration is small but high-value (embedded portal, deep +// links), so it runs on Opus 4.8; the broader full-API path runs on cheap Haiku +// 4.5. Defaults to Haiku when the mode is unknown. +function modelForMode( + mode: 'full_api' | 'customer_portal' | undefined, +): string { + return mode === 'customer_portal' ? 'claude-opus-4-8' : 'claude-haiku-4-5' +} + function buildSystemAppend( sdk: Sdk, workspaceName: string,