From 92a15a751be82b9079be8669eec728d3b5d7f6ec Mon Sep 17 00:00:00 2001 From: hardy30894 Date: Thu, 22 Oct 2026 22:18:58 -0400 Subject: [PATCH 1/3] feat: keep output that is usually read whole in view On 1,491 recorded sessions a block is reopened 15% of the time under 500 tokens and up to 87% at a few thousand, and every reopen costs an extra model turn. A reopen policy, per command class and size, now decides whether a block may be offloaded; when it may not, only inline codecs apply. MCP optimize takes optional tool and command arguments and exec uses its own command. The built-in rates come from that corpus; eval --learn fits rates on half the user's sessions, replays the other half with the gate, and writes ~/.secondwind/policy.json. On held-out sessions the learned gate cut reopens per session from 23.6 to 4.8 with no unfaithful block. The optimize description no longer claims query helps text. --- README.md | 2 +- crates/cli/src/main.rs | 287 ++++++++++++++++++------- crates/cli/src/mcp.rs | 19 +- crates/cli/tests/gate.rs | 141 +++++++++++++ crates/optimize/src/counterfactual.rs | 39 +++- crates/optimize/src/lib.rs | 1 + crates/optimize/src/policy.rs | 200 ++++++++++++++++++ crates/optimize/src/reopen_rates.json | 291 ++++++++++++++++++++++++++ 8 files changed, 903 insertions(+), 77 deletions(-) create mode 100644 crates/cli/tests/gate.rs create mode 100644 crates/optimize/src/policy.rs create mode 100644 crates/optimize/src/reopen_rates.json diff --git a/README.md b/README.md index 933bbf1..3fa0dfa 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,7 @@ Lossless *and* cheap is easy to get wrong. A few things that make it hold: | `secondwind check` | verify the install and agent integration | | `secondwind optimize ` | compress one tool-output block and print the result | | `secondwind verify ` | re-check a compressed wire against its fidelity certificate | -| `secondwind eval` | replay your recorded sessions through the optimizer: tokens sent, reopens, net savings and faithfulness per tool and command | +| `secondwind eval` | replay your recorded sessions through the optimizer: tokens sent, reopens, net savings and faithfulness per tool and command (`--learn` fits the reopen gate to your history) | | `secondwind exec -- ` | compress one command's output, shell-filter style (`-c '