-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Problem
When inputs or schemas exceed token budgets, we need graceful handling instead of hard failures.
Dependencies
- Requires: Add basic token counting and budget warnings #39 (basic token counting)
Proposed Solution
Implement intelligent truncation strategies:
-
Input truncation
- Truncate from middle (keep start/end context)
- Preserve structure (complete sentences/paragraphs)
- Add truncation markers: "...[truncated X tokens]..."
- Log original vs. truncated length
-
Schema simplification
- Remove field descriptions if over budget
- Omit optional fields
- Simplify complex nested structures
- Warn user about simplification
-
Prioritization
interface TruncationConfig {
strategy: 'middle' | 'end' | 'start';
preserveStructure: boolean;
prioritize: 'input' | 'schema';
}- User control
- CLI flag:
--max-input-tokens - CLI flag:
--truncate-strategy middle|end|start - Config file support
- CLI flag:
Acceptance Criteria
- Input truncation implementation
- Schema simplification logic
- Truncation preserves text structure
- Clear warnings about data loss
- User-configurable strategies
- Tests for different content types
- Documentation with examples
Related
- Parent: Improve LLM prompt engineering and clarity #30 (closed - split into focused issues)
- Prerequisite: Add basic token counting and budget warnings #39 (token counting)
- Follow-up: Advanced chunking (separate issue)
Reactions are currently unavailable