diff options
| author | Dax Raad <[email protected]> | 2025-09-12 06:41:55 -0400 |
|---|---|---|
| committer | opencode <[email protected]> | 2025-09-12 10:45:44 +0000 |
| commit | 0290b4aaf0fddfbc6030f8758b8c2309e4300909 (patch) | |
| tree | 2af481897d6cdc4814a5c637d1d606828ad1e8ec | |
| parent | 4ceee534809dd3b0646c0d1baaf7863628bdff0b (diff) | |
| download | opencode-0290b4aaf0fddfbc6030f8758b8c2309e4300909.tar.gz opencode-0290b4aaf0fddfbc6030f8758b8c2309e4300909.zip | |
ignore: internal
| -rw-r--r-- | packages/opencode/src/session/index.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 8f8f42e04..d333828b8 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -1116,7 +1116,7 @@ export namespace Session { item.callback(result) } state().queued.delete(input.sessionID) - Session.microcompact(input) + Session.prune(input) return result } @@ -1899,7 +1899,10 @@ export namespace Session { return count > usable } - export async function microcompact(input: { sessionID: string }) { + // goes backwards through parts until there are 40_000 tokens worth of tool + // calls. then erases output of previous tool calls. idea is to throw away old + // tool calls that are no longer relevant. + export async function prune(input: { sessionID: string }) { const msgs = await messages(input.sessionID) let sum = 0 for (let msgIndex = msgs.length - 2; msgIndex >= 0; msgIndex--) { @@ -1912,7 +1915,7 @@ export namespace Session { if (part.state.time.compacted) return sum += Token.estimate(part.state.output) if (sum > 40_000) { - log.info("microcompacting", { + log.info("pruning", { sum, id: part.id, }) |
