mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
fix: always send maxOutputTokens; default 16000
Unset does not mean the model's maximum — the provider fills in its own, and Bedrock's is 4096 (measured: converse with no inferenceConfig on us.anthropic.claude-opus-5 returns stopReason=max_tokens at exactly 4096). A 30-cell diagram is ~3000 tokens of XML, so anything larger arrived as truncated JSON and nothing reached the canvas. Small diagrams fitted, which made it look intermittent.
This commit is contained in:
@@ -493,9 +493,9 @@ IMPORTANT: The "Current diagram XML" is the SINGLE SOURCE OF TRUTH for what's on
|
||||
const result = streamText({
|
||||
model,
|
||||
abortSignal: req.signal,
|
||||
...(process.env.MAX_OUTPUT_TOKENS && {
|
||||
maxOutputTokens: parseInt(process.env.MAX_OUTPUT_TOKENS, 10),
|
||||
}),
|
||||
// Must be sent: unset means the provider's own default, and Bedrock's is 4096 —
|
||||
// enough for a small diagram, so larger ones were cut off mid-attribute.
|
||||
maxOutputTokens: Number(process.env.MAX_OUTPUT_TOKENS) || 16000,
|
||||
stopWhen: stepCountIs(5),
|
||||
// Repair truncated tool calls when maxOutputTokens is reached mid-JSON
|
||||
experimental_repairToolCall: async ({ toolCall, error }) => {
|
||||
|
||||
Reference in New Issue
Block a user