fix(core): bound consumed job results - #47030
Merged
Merged
Conversation
opencode-agent
Bot
force-pushed
the
consumed-job-cache
branch
from
September 18, 2026 14:32
2da7524 to
b8d84fd
Compare
opencode-agent
Bot
force-pushed
the
consumed-job-cache
branch
from
September 18, 2026 14:42
b8d84fd to
bd9a891
Compare
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.
Summary
Bound the process-global Job service's consumed terminal history to 25 entries, instead of keeping every completed shell/subagent job for the server's lifetime. Evict the whole record so its output, metadata, and completed Deferred snapshots can be collected.
This is a separate alternative to #46087, not stacked on it. The overlap was identified during implementation and the requester explicitly preferred a separate PR. This variant uses a smaller, count-only cache ordered by first consumption, removes acknowledged background records immediately, and keeps the patch limited to production code. It does not implement a UTF-8 output-byte budget.
Retention policy
start()toblock()/wait().block(), explicitcancel(), or non-recoverablewait()makes a job eligible for the 25-entry history. Repeated reads do not refresh its position.wait()alone does not consume the result, preserving the existingwait → backgroundhandoff, including immediately failed work.completeBackground()removes the durable marker and the matching terminal in-memory record under the registry lock.No tool, public HTTP/protocol, database schema, configuration, or installed-binary changes. The separate Shell cache and transcript/output handling are unchanged.
Scope of the bound: this is a history-entry bound, not a hard cap on total Job or server memory. Running work, unconsumed handoffs, pending notifications, caller-held results, and the size of individual result/metadata objects are outside the 25-entry bound. A producer that never consumes its result still owns that handoff.
Evidence
An isolated installed
opencode2 v0.0.0-dev-18911shell-tool probe observed 32 completed Job records after warm-up, 132 after 100 further commands, and the same 132 after idle GC. All job scopes were closed; each record still referenced a fixture-tagged output node, while the separate Shell cache stayed at 25 entries. Session message history stayed empty.Those are pre-fix installed-server measurements, not a before/after memory claim for this patch. Bun's exported Map edges are incomplete, as documented in the report. Raw snapshots remain private.
Validation
bun typecheck, targeted Oxlint, both Effect AST rule sets, Prettier, andgit diff --checkpassed.