Repository navigation
feat(agents): stream the usage log instead of holding it whole - #290
Merged
artempartos merged 1 commit intoSep 17, 2026
Merged
artempartos merged 1 commit into
artempartos merged 1 commit into
Conversation
`#collect_usage` took its log as a String, which is why `/var/log/mitm/http.log` had to be copied out of the container and materialised here — and copying it is what failed. Over the 30 days to 2026-09-17, cleanup ran for 277 of the 281 cursor_cli/grok/codex sessions while only 52 produced an `http.log` row, the largest 2.04 MB; exactly one session in that window failed inside the cleanup phase. The ceiling was the transfer, not the time budget, so moving the work to a job would have fixed the wrong thing. Those logs now take the same direct upload as every other, and come back as a Sessions::LogSource that reads the stored object in chunks. Every parser was already written as `log_content.each_line`, and a String is still one, so the small-log path is untouched and no adapter can tell the difference. `#usage_log_paths`, added one commit ago to keep these on the bounded read, is gone with the reason for it. Codex counted the log's lines to log that count, which is a third full pass over something that no longer fits; it reports the size alone now. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
artempartos
merged commit Sep 17, 2026
990474d
into
artempartos/container-side-log-upload
7 checks passed
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 26, 2026
Signed-off-by: Alex <[email protected]>
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 27, 2026
…294 inside, #290 gates, suspended backfill Signed-off-by: Alex <[email protected]>
NOX73
added a commit
that referenced
this pull request
Nov 27, 2026
* docs(tools): tech design for attached-only session tools Signed-off-by: Alex <[email protected]> * docs(tools): update tool attachment design with plumbing, migration and flag decisions Signed-off-by: Alex <[email protected]> * docs(tools): drop feature flag, one migration, templates pull request in tool-attachment design Signed-off-by: Alex <[email protected]> * docs(tools): update tool-attachment index entry Signed-off-by: Alex <[email protected]> * docs(tools): tool attachment design round 4 (#290) Signed-off-by: Alex <[email protected]> * docs(tools): tool attachment design round 5, tracker and repository reachability, no production ids Signed-off-by: Alex <[email protected]> --------- Signed-off-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
NOX73
added a commit
that referenced
this pull request
Nov 27, 2026
…295) (#904) * docs(integrations): tech design for integrations chosen per session (#295) Signed-off-by: Alex <[email protected]> * docs(integrations): update tech design for #295 after review round 1 Signed-off-by: Alex <[email protected]> * Design: address review findings on session integrations (restore, Coder identity, tenant checks, backfill) Signed-off-by: Alex <[email protected]> * docs(integrations): design round 4 for #295: no Coder identity rules, #294 inside, #290 gates, suspended backfill Signed-off-by: Alex <[email protected]> * docs(integrations): fix models test line in session integrations design Signed-off-by: Alex <[email protected]> --------- Signed-off-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
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.
Why, corrected
I said the fix for
cursor_cli/grok/codexwas to move#collect_usageout of the cleanup phase into a job. That was the wrong diagnosis, and measuring it says so plainly. Over the 30 days to 2026-09-17, for those three runtimes:And the sizes of the ones that did arrive: p50 818 KB, largest ever 2.04 MB. Nothing bigger has ever survived.
So the phase was never the problem. The transfer was — a tar copy of the whole file through the API server, with a practical ceiling around 2 MB against a log that reaches 90 MB. A job would have moved work that was not failing for the reason it was moved.
What this does instead
#collect_usagetook its log as a String, and that is the only reason the bytes had to be here at all.#usage_log_paths— added one commit earlier to hold them back — goes away with the reason for it.Sessions::LogSource, which reads the stored object a chunk at a time and yields lines.each_line(GrokAdapter#extract_events_from_mitm,CursorCliAdapter#build_rpc_windows,CodexAdaptertwice over). A String is still aneach_line, so the small-log path is untouched and no adapter can tell which it got.Memory, the transport ceiling and the phase budget all drop out together. A job stays available if wall-clock later argues for one — but that would be a different reason, measured.
Codex counted the log's lines in order to log that count, which is a third full pass over something that no longer fits. It reports the size alone.
Care taken in the streaming
CHUNK_BYTES + 100.Verification
test/services/agents,test/services/sessions,test/services/container_strategies,test/temporal: 838 runs, 2346 assertions, 0 failures, 0 errors.rubocopclean on the changed files,brakemanclean (0 warnings).New coverage:
LogSourceagainst the cases above, plus the contract itself —GrokAdapter#collect_usageproduces the same token breakdown from aLogSourceas from the String the existing test feeds it. In the collector, an uploaded log now comes back as a stream, and the log an adapter parses is uploaded like any other.🤖 Generated with Claude Code