linshenkx/prompt-optimizer · error · Error
Requirements must not exceed 10,000 characters
Error message
Requirements must not exceed 10,000 characters
What it means
ParameterAdapter.validateRequirements throws this when requirements.length exceeds 10,000 characters — a hard cap on the requirements/description input, tighter than the prompt limit (50,000).
Source
Thrown at packages/mcp-server/src/adapters/parameter-adapter.ts:37
/**
* 验证模板输入
*/
static validateTemplate(template?: string): void {
if (template !== undefined && (typeof template !== 'string' || template.trim().length === 0)) {
throw new Error('Template must be a non-empty string');
}
}
/**
* 验证需求描述输入
*/
static validateRequirements(requirements: string): void {
if (!requirements || typeof requirements !== 'string' || requirements.trim().length === 0) {
throw new Error('Requirements must be a non-empty string');
}
if (requirements.length > 10000) {
throw new Error('Requirements must not exceed 10,000 characters');
}
}
}
View on GitHub (pinned to 3e677b1d9f)
Solutions
- Summarize requirements to under 10,000 characters before the call
- Put the detailed spec in the prompt (50k limit) and keep requirements as a concise statement
- Chunk long specs across multiple calls
Example fix
// before
await tool.call({ requirements: fullPrd });
// after
await tool.call({ requirements: fullPrd.slice(0, 10000), prompt: fullPrd }); Defensive patterns
Strategy: validation
Validate before calling
const MAX_REQ = 10000; if (requirements.length > MAX_REQ) requirements = requirements.slice(0, MAX_REQ);
Type guard
const isWithinRequirementsLimit = (r: string): boolean => r.length <= 10000;
Try / catch
try { await call({ requirements }); } catch (e) { if ((e as Error).message.includes('10,000')) { await call({ requirements: requirements.slice(0, 10000) }); } else throw e; } Prevention
- Remember the requirements limit (10k) is lower than the prompt limit (50k)
- Summarize long specs; move detail into the prompt field
When it happens
Trigger: Calling a requirements-based tool with a requirements string over 10,000 characters, e.g. pasting a full PRD or spec document into the requirements field.
Common situations: Inlining entire specification documents rather than a summary; concatenating ticket descriptions plus acceptance criteria plus comments; assuming the requirements limit matches the prompt limit (it's 5x smaller).
Related errors
- Prompt must not exceed 50,000 characters
- Requirements must be a non-empty string
- User prompt is required
- Prompt must be a non-empty string
- Template must be a non-empty string
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/ff28f8d129caed12.
Report an issue: GitHub.