diff --git a/scripts/deploy-pascal-production.sh b/scripts/deploy-pascal-production.sh index b95865e72..61526e394 100755 --- a/scripts/deploy-pascal-production.sh +++ b/scripts/deploy-pascal-production.sh @@ -239,6 +239,7 @@ write_pascal_env() { printf 'PASCAL_AGENT_API_KEY=%s\n' "$secret" printf 'PASCAL_AGENT_BASE_URL=%s/api/internal/pascal-agent/v1\n' "$MAIN_INTERNAL_URL" printf 'PASCAL_AGENT_MODEL=main-agent\n' + printf 'PASCAL_AGENT_MAX_OUTPUT_TOKENS=%s\n' "${PASCAL_AGENT_MAX_OUTPUT_TOKENS:-8192}" printf 'PASCAL_AGENT_MAX_STEPS=%s\n' "${PASCAL_AGENT_MAX_STEPS:-18}" printf 'PASCAL_AGENT_STEP_TIMEOUT_MS=%s\n' "${PASCAL_AGENT_STEP_TIMEOUT_MS:-90000}" printf 'PASCAL_AGENT_TOTAL_TIMEOUT_MS=%s\n' "${PASCAL_AGENT_TOTAL_TIMEOUT_MS:-300000}" diff --git a/services/pascal-editor/.env.example b/services/pascal-editor/.env.example index 1c1b5eaa2..2220d26d5 100644 --- a/services/pascal-editor/.env.example +++ b/services/pascal-editor/.env.example @@ -13,6 +13,7 @@ # Optional agent safety limits. # PASCAL_AGENT_MAX_STEPS=18 +# PASCAL_AGENT_MAX_OUTPUT_TOKENS=8192 # PASCAL_AGENT_STEP_TIMEOUT_MS=90000 # PASCAL_AGENT_TOTAL_TIMEOUT_MS=300000 diff --git a/services/pascal-editor/apps/editor/app/api/agent/chat/route.ts b/services/pascal-editor/apps/editor/app/api/agent/chat/route.ts index 403d821f3..7ff5ed4db 100644 --- a/services/pascal-editor/apps/editor/app/api/agent/chat/route.ts +++ b/services/pascal-editor/apps/editor/app/api/agent/chat/route.ts @@ -166,7 +166,7 @@ export async function POST(request: Request) { stepNumber, }), }), - maxOutputTokens: 1600, + maxOutputTokens: config.maxOutputTokens, messages, model: provider.chat(config.model), stopWhen: stepCountIs(config.maxSteps), diff --git a/services/pascal-editor/apps/editor/lib/pascal-agent-config.test.ts b/services/pascal-editor/apps/editor/lib/pascal-agent-config.test.ts index 1a0df1aac..fb86c5eb0 100644 --- a/services/pascal-editor/apps/editor/lib/pascal-agent-config.test.ts +++ b/services/pascal-editor/apps/editor/lib/pascal-agent-config.test.ts @@ -11,6 +11,7 @@ describe('Pascal agent configuration', () => { expect(config.configured).toBe(false) expect(config.baseUrl).toBe('https://api.openai.com/v1') + expect(config.maxOutputTokens).toBe(8192) expect(config.maxSteps).toBe(18) }) @@ -19,6 +20,7 @@ describe('Pascal agent configuration', () => { PASCAL_AGENT_API_KEY: ' test-key ', PASCAL_AGENT_BASE_URL: 'https://models.example/v1/', PASCAL_AGENT_MAX_STEPS: '999', + PASCAL_AGENT_MAX_OUTPUT_TOKENS: '999999', PASCAL_AGENT_MODEL: ' design-model ', PASCAL_AGENT_STEP_TIMEOUT_MS: '1000', PASCAL_AGENT_TOTAL_TIMEOUT_MS: '9999999', @@ -29,6 +31,7 @@ describe('Pascal agent configuration', () => { baseUrl: 'https://models.example/v1', configured: true, maxSteps: 40, + maxOutputTokens: 32_768, model: 'design-model', stepTimeoutMs: 10_000, totalTimeoutMs: 600_000, diff --git a/services/pascal-editor/apps/editor/lib/pascal-agent-config.ts b/services/pascal-editor/apps/editor/lib/pascal-agent-config.ts index daeb17bbf..c041a1cf6 100644 --- a/services/pascal-editor/apps/editor/lib/pascal-agent-config.ts +++ b/services/pascal-editor/apps/editor/lib/pascal-agent-config.ts @@ -2,6 +2,7 @@ export interface PascalAgentConfig { apiKey: string baseUrl: string configured: boolean + maxOutputTokens: number maxSteps: number model: string stepTimeoutMs: number @@ -31,6 +32,7 @@ export function getPascalAgentConfig(env: NodeJS.ProcessEnv = process.env): Pasc apiKey, baseUrl, configured: apiKey.length > 0 && model.length > 0, + maxOutputTokens: readBoundedInteger(env.PASCAL_AGENT_MAX_OUTPUT_TOKENS, 8192, 1024, 32_768), maxSteps: readBoundedInteger(env.PASCAL_AGENT_MAX_STEPS, 18, 4, 40), model, stepTimeoutMs: readBoundedInteger(env.PASCAL_AGENT_STEP_TIMEOUT_MS, 90_000, 10_000, 180_000),