Skip to content

perf(rules): compact large edit prompts - #47

Open
Hiro-Chiba wants to merge 1 commit into
nizos:mainfrom
Hiro-Chiba:agent/compact-large-edit-prompts
Open

perf(rules): compact large edit prompts#47
Hiro-Chiba wants to merge 1 commit into
nizos:mainfrom
Hiro-Chiba:agent/compact-large-edit-prompts

Conversation

@Hiro-Chiba

Copy link
Copy Markdown
Contributor

What

This is an initial attempt at reducing the input that enforceTdd sends for a localized Edit in a large file.

Adapters still produce the same canonical Write with the full post-edit content. They also retain the already validated Edit descriptor as non-serialized metadata. For post-images of at least 64 KiB, enforceTdd uses that descriptor only when it is at least four times smaller than the full content. Smaller or broad edits keep the existing full-context path.

Would this projection and fallback threshold fit the rule's intended trade-off between context and validator latency?

Why

A one-line Edit currently makes the validator receive the complete post-image. In a local 50 MiB case, that produced a 52,435,726-character prompt even though the actual replacement was small.

The projected prompt was 7,191 characters. Prompt construction dropped from 35.03 ms to 0.26 ms, while the canonical full post-image remained available to every other rule.

Compatibility

  • The public Action shape and JSON representation are unchanged.
  • Existing content and custom rules still receive the full post-image.
  • Small files, broad edits, and fastPath retain the full before/after behavior.
  • Claude Code, GitHub Copilot CLI, GitHub Copilot Chat, and Antigravity use the same projection metadata.

Verification

  • npm run checks
  • 58 test suites passed
  • 544 tests passed, with 26 existing skips
  • Local 1 MiB, 10 MiB, and 50 MiB Edit benchmarks using the CLI's 1 MiB read cap
  • A 20 MiB full-fallback benchmark to check that rejected descriptors do not add CPU or memory overhead

@Hiro-Chiba
Hiro-Chiba force-pushed the agent/compact-large-edit-prompts branch from 40739c8 to 0cc913f Compare July 18, 2026 11:33
@Hiro-Chiba
Hiro-Chiba marked this pull request as ready for review July 18, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant