Bugfix: Why did chat show '413 Payload Too Large' after agent loop c...
Documentation for Sessions
🐛 Bugfix: Why did chat show '413 Payload Too Large' after agent loop c...
Date: 2026-03-09
Time: 19:37:55 UTC
Session: gspace1-191.5
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
Why did chat show '413 Payload Too Large' after agent loop completed with many tool calls?
Task: Not specified
🎯 Decision Made
Chosen:
Raised JSON body limit from NestJS default 100KB to 5MB in backend-ai-api main.ts. Also raised frontend chat timeout from 60s to 5min, and fixed deprecated haiku model ID.
Options Considered:
- Truncate tool metadata before persistence
- Raise body limit (chosen)
- Compress payload with gzip
- Stream persistence in chunks
💭 Reasoning
Three cascading issues: (1) Agent loop with 18 tool calls (recall_memory, search_decisions) produced a response with embedded tool metadata exceeding 100KB NestJS default. Frontend tried to persist this to /ai-api/sessions/.../messages and got 413. (2) The 60s frontend timeout was too aggressive for agent loops that routinely take 2-4 minutes with tool calls, causing 'response is taking longer than expected' before completion. (3) SmartRouter fallback used deprecated model claude-3-5-haiku-20241022 which returned 404, forcing OpenAI failover.
📁 Files Involved
APIs/backend-ai-api/src/main.tslibs/libs-ai/vitto-chat/src/lib/services/vitto-chat-engine.service.tsAPIs/backend-vitto-api/src/app/llm/smart-router.service.ts
🔗 Related
- Decision ID:
dev_1773085075679_8akayku - Session: 191
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation