Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(context): disable old tool result clearing by default (#2525)
Call Whitee9276acf2dae
diff --git a/core/agent_core/harness/context.py b/core/agent_core/harness/context.pyindex 578256dc4..63bdc77e0 100644--- a/core/agent_core/harness/context.py+++ b/core/agent_core/harness/context.py@@ -218,7 +218,9 @@ class ContextConfig:host: Optional[ContextHost] = None#: This Session's scratch directory; checkpoint turns may write only there.scratch_dir: Optional[str] = None- clear_tool_results: bool = True+ #: Opt-in policy for proactively replacing old tool results with the cleared placeholder. New Sessions keep+ #: original results until normal compaction unless an adapter explicitly enables this experiment.+ clear_tool_results: bool = Falseclock: Callable[[], float] = field(default=time.time, repr=False)diff --git a/docs/plans/agent-core-contracts/context.md b/docs/plans/agent-core-contracts/context.mdindex 2df1e32e7..4ba9a1d62 100644--- a/docs/plans/agent-core-contracts/context.md+++ b/docs/plans/agent-core-contracts/context.md@@ -1,6 +1,6 @@# C-9 Context management-Frozen 2026-10-04 by owner decision; amended 2026-10-12 by owner decision (the estimate of opaque reasoning payloads+Frozen 2026-10-04 by owner decision; amended 2026-10-13 by owner decision (the estimate of opaque reasoning payloadsand the anchor's validity, §2; the cache lifetime per route, §3; the checkpoint request's output budget, §1 and §6).The `harness` owns the rules (`core/agent_core/harness/context.py`, `projection.py`); the loop applies them beforeevery model request (`core/agent_core/agent/loop.py`); the adapter supplies the Session-specific parts (§9). Row@@ -10,7 +10,8 @@ shapes: [`transcript-rows.schema.json`](transcript-rows.schema.json); events:Three tiers, cheapest first:1. **Output governance at write time** (C-7): no tool result exceeds 2,000 lines / 50 KB.-2. **Clearing old tool results**, recorded as `context_edit` rows (§4). On by default.+2. **Optional clearing of old tool results**, recorded as `context_edit` rows (§4). Off by default; an adapter may+ enable it for evaluation or rollout.3. **Checkpoint**, recorded as a `context_compaction` row, written by the model in a forked request (§5–§7).Compaction and clearing only append rows; they never rewrite or delete one. A fork anchored before a checkpoint@@ -113,9 +114,9 @@ before a retry alike:to its own tool results (§6), one helper for both. The run continues and compacts as usual. A batch that does notfit even with every result cut to its note, or a last unit that is an input, stops the run: the provider neversees the request. A batch that fits once the conversation moves out is never cut; the ladder makes room for it.-2. **Clear** (§4) when the provider cache is cold (the request's route has not used it for longer than its- lifetime, below; after a restart, measured from the response rows' `created_at`) or `est >= 0.8 * T`, which does- not depend on the lifetime.+2. **Clear**, when enabled (§4), if the provider cache is cold (the request's route has not used it for longer than+ its lifetime, below; after a restart, measured from the response rows' `created_at`) or `est >= 0.8 * T`, which+ does not depend on the lifetime.3. **Checkpoint** when `est >= T`, the run has not stopped compacting (§10), and there is something to summarize,at most once per model request: a normal checkpoint (§6, reason `threshold`) when the fork it would send can fit,otherwise the overflow ladder from (b) (§8, reason `overflow`). A checkpoint request that overflows continues at@@ -151,9 +152,15 @@ content is committed as a non-final response, and the run ends `context_exhausterequests (§6) never run this stage (no clearing, checkpoint, or ladder; one compaction is in flight per Session);each is sent only when it can fit.-## 4. Clearing old tool results+## 4. Optional clearing of old tool results-- Eligible: results of `read` and `bash` in the projected context (terminal screen snapshots join when they exist).+This policy is disabled by default. When disabled, no new `clear_old_tool_result` rows are written; the normal+`fit_tool_result` edits for a newest batch that cannot fit, checkpoints, and overflow ladder remain active. Existing+`clear_old_tool_result` rows continue to project as recorded, so disabling the policy never changes already persisted+Sessions.++- Eligible when enabled: results of `read` and `bash` in the projected context (terminal screen snapshots join when+ they exist).- Protected: results after the second-latest input (the last 2 user turns; with fewer than 2 inputs since the latestcheckpoint, all of them), the newest 5 eligible results, and results already cleared (a result cut to fit, §3, canstill be cleared). A skill load clears like anydiff --git a/tests/agent_core/agent/test_compaction.py b/tests/agent_core/agent/test_compaction.pyindex 7244e107f..1859f5ab5 100644--- a/tests/agent_core/agent/test_compaction.py+++ b/tests/agent_core/agent/test_compaction.py@@ -44,6 +44,7 @@ from core.agent_core.cancel import CancelTokenfrom core.agent_core.harness.context import (CHECKPOINT_REQUEST,CHECKPOINT_TRUNCATED,+ CACHE_TTL_UNKNOWN_S,TOOL_TRUNCATED,ContextConfig,StateRequest,@@ -1426,7 +1427,7 @@ CLAUDE = ModelEndpoint("anthropic", "http://model.invalid", "claude-opus-5-5", "async def test_clearing_runs_once_the_route_cache_has_gone_cold_and_spares_recent_turns(endpoint, lifetime):now = [1_000.0]store = InMemoryTranscriptStore(clock=lambda: now[0])- context = ContextConfig(clock=lambda: now[0])+ context = ContextConfig(clock=lambda: now[0], clear_tool_results=True)script = [*_long_context(9), *([Done(assistant(word))] for word in ("one", "two", "three", "four"))]model = Model(script)route = ModelSelection(endpoint, LARGE.capabilities)@@ -1451,6 +1452,27 @@ async def test_clearing_runs_once_the_route_cache_has_gone_cold_and_spares_recenassert store.transactions == [["context_edit"] * 4] # one transition, one transaction+async def test_old_tool_result_clearing_is_disabled_by_default():+ now = [1_000.0]+ store = InMemoryTranscriptStore(clock=lambda: now[0])+ model = Model([*_long_context(9), *([Done(assistant(word))] for word in ("one", "two", "three"))])+ agent = make_agent(+ model,+ store=store,+ tools=[reader(tokens(6_000))],+ selection=LARGE,+ context=ContextConfig(clock=lambda: now[0]),+ )+ await run(agent, row="turn-1")+ await run(agent, row="turn-2")+ now[0] += CACHE_TTL_UNKNOWN_S + 1+ await run(agent, row="turn-3")++ rows = await store.load("session")+ assert not [row for row in rows if row.kind == "context_edit"]+ assert not model.checkpoint_requests++#: A Model Hub Google hop as the adapter calls it: over Chat at the gateway, while the served-hop report names the#: Google protocol the gateway converted to (C-6). Its cache lifetime is unknown: an hour.GEMINI = ModelEndpoint("openai_chat", "http://model.invalid", "gemini-3-pro", "", provider="google")@@ -1463,7 +1485,7 @@ async def routed_turn(store, now, endpoint, scripts, row, served=None):origin = served or endpoint_origin(endpoint)model = Model([[replace(event, message=replace(event.message, origin=origin)) for event in s] for s in scripts])route = ModelSelection(endpoint, LARGE.capabilities)- context = ContextConfig(clock=lambda: now[0])+ context = ContextConfig(clock=lambda: now[0], clear_tool_results=True)agent = make_agent(model, store=store, tools=[reader(tokens(6_000))], selection=route, context=context)assert (await run(agent, row=row))[-1].reason == "completed"return [row for row in await store.load("session") if row.kind == "context_edit"]@@ -1505,7 +1527,12 @@ async def test_pressure_clearing_runs_on_a_warm_cache():route = ModelSelection(ENDPOINT, replace(SELECTION.capabilities, context_window=72_000, input_limit=None))script = [*_long_context(9), *([Done(assistant(word))] for word in ("one", "two", "three"))]model = Model(script, [[Done(assistant(CHECKPOINT))]])- agent = make_agent(model, tools=[reader(tokens(6_000))], selection=route)+ agent = make_agent(+ model,+ tools=[reader(tokens(6_000))],+ selection=route,+ context=ContextConfig(clear_tool_results=True),+ )for turn in ("turn-1", "turn-2", "turn-3"):assert (await run(agent, row=turn))[-1].reason == "completed"edits = [row for row in await agent.store.load("session") if row.kind == "context_edit"]@@ -1551,7 +1578,7 @@ async def test_a_return_to_a_long_reasoning_session_never_checkpoints_at_57_percscript = [*reads, *(responses_reply(value=word, reasoning=200) for word in ("noted", "two", "three"))]model = Model(script, [[Done(assistant(CHECKPOINT))]])route = ModelSelection(GPT, LARGE.capabilities)- context = ContextConfig(clock=lambda: now[0])+ context = ContextConfig(clock=lambda: now[0], clear_tool_results=True)agent = make_agent(model, store=store, tools=[reader(tokens(7_300))], selection=route, context=context)await run(agent, row="turn-1")await run(agent, row="turn-2")diff --git a/tests/test_transcript_store_contract.py b/tests/test_transcript_store_contract.pyindex aa8e5daf2..92ec65f63 100644--- a/tests/test_transcript_store_contract.py+++ b/tests/test_transcript_store_contract.py@@ -344,7 +344,7 @@ async def test_a_new_agent_anchors_on_the_stored_request_facts(c9):async def test_a_new_agent_clears_old_results_once_the_cache_has_gone_cold(c9):idle = [0.0]- context = ContextConfig(clock=lambda: time.time() + idle[0])+ context = ContextConfig(clock=lambda: time.time() + idle[0], clear_tool_results=True)reads = [[Done(assistant(calls=[ToolCallBlock(f"r{index}", "read", {"path": "f"})]))] for index in range(9)]model = Model([*reads, [Done(assistant("one"))], [Done(assistant("two"))]])agent = make_agent(model, store=c9.store, tools=[reader(tokens(6_000))], selection=LARGE, context=context)