aaif-goose / aaif-goose/goose

RLM (with no R) in goose? Context-as-variables.

未关闭
#11,215 2 条评论 0 个 reaction 已指派 2 人 已被 @DOsinga 认领 在 GitHub 查看
主要语言
Rust
星标
54.2k
派生
6.2k
平均合并
3 天 2 小时
30 天内合并 PR
262

描述

**What problem would this solve?**

On long, data-heavy tasks every cat, grep, or build log lands in the conversation, gets re-billed each turn, and is lost at compaction.
The model then re-reads files and re-derives results it already computed, wasting tokens and sometimes breaking correctness.

**What would a good outcome look like?**

An (opt-in?) session-long Python runtime where variables, imports, and functions persist across turns, across compaction, and (best-effort) across process restarts.
Large tool/file outputs bind to variables, so the model sees a capped preview plus a live inventory instead of the raw blob. Equal-or-better success at lower cost.

**Possible approaches**

Inspiration: [Recursive Language Models](https://arxiv.org/abs/2512.24601) (Zhang et al., MIT CSAIL). \
-- Note: this adopts the paper's context-as-variables idea but not its defining recursion - there are no recursive LLM sub-calls - so it is a persistent execution/context surface rather than a literal RLM.

I prototyped on a default-off platform extension with a single `python` tool:

- Stdlib-only Python subprocess (JSON-lines), no ipykernel/pyo3/zeromq, so zero new Rust deps and the toggle is the feature gate.
- `sh()`/`edit()` helpers so it runs pure or alongside developer.
- After a compaction, a `` block re-anchors the surviving variables so the model reuses them instead of recomputing.
- Per-variable pickle snapshots restore state on process restart.

Trade-offs: needs python3 in the env (errors clearly if absent); snapshots skip unpicklable values; Windows uses kernel-restart instead of cell interrupt.

**Additional context**

Terminal-Bench 2.1 A/B, stock developer+todo vs the pure RLM arm:

| Model | Suite | Pass (RLM vs stock) | Cost/trial |
|---|---|---|---|
| gpt-5.6-terra | 26-task, k=3 | 82.1% vs 78.2% | -58% |
| gpt-5.6-sol | 26-task, k=3 | 87.2% vs 82.1% | -58% |
| claude-opus-5 | 26-task, k=1 | 84.6% tie | -28% |
| gpt-5.6-terra | full 89-task, k=1 | 47.2% tie | -49% |

- Accuracy is parity across evals; every pass edge is within single-run noise.
- Cost win is robust; it holds across the full distribution, with 0 kernel deaths / 0 harness exceptions.
- The win is almost entirely fewer input tokens: data lives in variables, so ~65% less context is re-sent each turn (46K vs 133K tok on terra). RLM's cache hit rate is at parity with stock.
- Compaction-survival verified end-to-end: after a real compaction the re-anchor restores kernel variables and the model answers from them without recomputing.

Follow-up work (separate issue): add the paper's actual recursion at depth 1 - a leaf `llm()` sub-call over a variable's slices - and evaluate it on a long-context benchmark, where recursion is expected to add capability rather than a cost win.

- [x] I have verified this does not duplicate an existing feature request

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。