Usage is very high (#18) - #19
Merged
Merged
Conversation
Closes #18 Generated by coding-agent-loop run b328b7bb-cc7a-451c-b698-00fbcad54205.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18
What the agent did
This matches the plan's file list exactly. I'll leave version control to the harness as instructed (not committing).
Summary
Implemented the approved plan for issue #18 (cut per-run token usage) across three parts:
Part A — cache reads reported separately from fresh input
internal/claude/runner.go: addedFreshTokensIn(),CacheWriteTokens(),CacheReadTokens()accessors.internal/store/store.go: new migration (entry 3) addingtokens_cache_read/tokens_cache_writecolumns;Run,runColumns,scanRunupdated;RecordUsagenow takes aRunUsagestruct instead of 7 positional args.loop.go,prcomments.go, bothRecordUsagecalls plusclaude_doneevent details) and two instore_test.go, plus a new migration testTestMigrationAddsCacheTokenColumns.internal/web/assets/app.js: newfmtTokensBreakdownhelper, used in the runs table and run detail view.internal/discord/notifier.go: Tokens embed field now shows the fresh/written/cached split.Part B — trim the harness prompt (
internal/orchestrator/prompt.go)maxBodyChars12000→6000,maxCommentChars2000→1200,maxCommentsInclu12→6), addedmaxPlanChars,maxPRCommentsInclu,maxDiffHunkChars,maxReviewsInclu.issueContextnow filters out harness-authored comments (isAgentComment) and bare approvals (isApproval) before applying the comment window, and omits the### Discussionheader when nothing survives the filter.implementTaskPrompt/planTaskPromptcap the plan withtruncate;prCommentTaskPromptcaps comment count, diff-hunk size, and review count.Part C — stop the CLI loading ambient operator context (
internal/claude/runner.go)--strict-mcp-config,--disable-slash-commands,--exclude-dynamic-system-prompt-sections,--autocompact 200000as hardcoded args, beforeExtraArgs. AddedTestRunPassesTokenReductionFlags.Also updated
README.md's Prompts section and the verbatimclaude …invocation block to document all of this.Verification:
go build ./...succeeds;go test ./...passes for every package exceptinternal/git, which fails onmaintoo (pre-existing environmental identity-config mismatch, unrelated to any file this change touches — verified no diff exists ininternal/git).Note for reviewer: early in the session I accidentally ran a bare
git stash pushthat briefly stashed this in-progress work; I recovered it immediately viagit stash apply <sha>(not pop) and dropped the entry — finalgit statusconfirms only the intended 11 files are modified, matching the plan's file list exactly.Verification
Tests failed (
make test). This PR is a draft — the failure is reported rather than hidden, so you can judge whether the change is salvageable.Test output (tail)
Changes
Opened automatically by coding-agent-loop (run
b328b7bb-cc7a-451c-b698-00fbcad54205, attempt 3, modelclaude-sonnet-5, cost $2.2602, sessiond328a89e-cafd-4133-a8b1-2435aa7f4c48). Nothing here has been reviewed by a human yet.