-
Notifications
You must be signed in to change notification settings - Fork 0
feat: reduce AI context token consumption by collapsing successful bu… #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ilds, using tail-biased truncation, and relaxing verbatim output instructions Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@copilot review it |
|
@killme2008 I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR reduces AI context usage from devtap drains by collapsing successful runs into a single summary line, biasing truncation toward the tail of logs, and relaxing “verbatim output” instructions for successful builds.
Changes:
- Add
mcp.CollapseSuccessfulto replace successful run output (exit code 0) with a single-line omission summary. - Switch message truncation to use tail-biased truncation (
TruncateWithRatio(..., 0.8)) to preserve end-of-log errors. - Update MCP/tooling instructions/docs to acknowledge successes briefly and only show verbatim output on failures.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| skills/devtap-get-build-errors/SKILL.md | Updates skill guidance to avoid repeating successful output and keep failures verbatim. |
| internal/mcp/truncate.go | Uses tail-biased truncation for per-message line truncation. |
| internal/mcp/server.go | Updates tool description and collapses successful runs before truncation/formatting. |
| internal/mcp/collapse.go | Implements collapsing of successful runs into a single summary line. |
| internal/mcp/collapse_test.go | Adds unit tests covering collapse behavior across multiple run/tag scenarios. |
| internal/filter/truncate.go | Introduces TruncateWithRatio and redefines Truncate as a 50/50 wrapper. |
| internal/filter/truncate_test.go | Adds tests for tail-biased truncation and edge cases. |
| internal/adapter/instructions.go | Updates injected instruction block to not repeat successful output. |
| cmd/devtap/drain.go | Collapses successful runs before truncation in CLI drain paths. |
| CLAUDE.md | Updates documented output expectations for successful vs failed builds. |
Comments suppressed due to low confidence (1)
internal/filter/truncate.go:50
- TruncateWithRatio can return
maxLines + 1entries when truncation occurs because it adds an omission marker in addition tohead+tail==maxLines. This means callers like mcp.TruncateMessages can exceed their overall line budget (and may clear later messages earlier than intended). If maxLines is meant to be a hard cap, adjust the algorithm so the omission marker is included in the budget (e.g., reserve 1 line for the marker and use head+tail=maxLines-1 when truncating).
omitted := len(lines) - head - tail
result := make([]string, 0, head+1+tail)
result = append(result, lines[:head]...)
result = append(result, fmt.Sprintf("... (%d lines omitted)", omitted))
result = append(result, lines[len(lines)-tail:]...)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Dennis Zhuang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Dennis Zhuang <[email protected]>
…ilds, using tail-biased truncation, and relaxing verbatim output instructions