Skip to content

Add smart input truncation and schema simplification #40

@michaeldistel

Description

@michaeldistel

Problem

When inputs or schemas exceed token budgets, we need graceful handling instead of hard failures.

Dependencies

Proposed Solution

Implement intelligent truncation strategies:

  1. 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
  2. Schema simplification

    • Remove field descriptions if over budget
    • Omit optional fields
    • Simplify complex nested structures
    • Warn user about simplification
  3. Prioritization

interface TruncationConfig {
  strategy: 'middle' | 'end' | 'start';
  preserveStructure: boolean;
  prioritize: 'input' | 'schema';
}
  1. User control
    • CLI flag: --max-input-tokens
    • CLI flag: --truncate-strategy middle|end|start
    • Config file support

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions