fix: mark AI tool execution route as dynamic to prevent build-time WASM error

Add `export const dynamic = 'force-dynamic'` to `/api/tools/execute/[...slug]`
to prevent Next.js from attempting static generation at build time.

The AI SDK (used via executeToolWithAgent) requires tiktoken_bg.wasm which
cannot be loaded during static generation. Marking as dynamic ensures the
route is only executed at runtime.

Note: This partially addresses the build error but further investigation needed
for complete resolution of tiktoken WASM loading in Next.js 16 + Turbopack.

Relates to: "Error: Missing tiktoken_bg.wasm"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-11-30 01:42:04 +10:00
parent 30f581cbc3
commit 38cc823a58

View file

@ -11,6 +11,7 @@ import { type NextRequest, NextResponse } from 'next/server';
// Use Node.js runtime for SSE streaming
export const runtime = 'nodejs';
export const maxDuration = 60; // 60 seconds timeout
export const dynamic = 'force-dynamic'; // Prevent static generation for AI SDK routes
interface ExecuteRequest {
prompt: string;