Skip to content

Unbounded prompt construction in ReduceSynthesis and GroupSynthesis #73

@marklubin

Description

@marklubin

Problem

ReduceSynthesis and GroupSynthesis concatenate all input artifacts into a single prompt string with no token/size limit:

artifacts_text = "\n\n---\n\n".join(f"### {a.label}\n{a.content}" for a in sorted_inputs)

For large corpora (hundreds or thousands of artifacts), this will exceed context windows and cause hard failures with no useful error message.

Impact

  • O(total_input_size) memory and token usage
  • Silent failures when prompt exceeds model context window
  • Affects both ReduceSynthesis (all inputs → 1 output) and GroupSynthesis (per-group concatenation)

Suggested approach

  • Add an optional max_tokens or context_budget parameter (like CoreSynthesis has)
  • Truncate or chunk inputs when they'd exceed the limit
  • Log a warning when truncation occurs
  • Consider automatic chunking with recursive reduce for very large input sets

Scope

This is a scale optimization — the current implementation works correctly for typical pipeline sizes (dozens of artifacts). It only becomes a problem with large corpora.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions