Skip to main content

Module context_browse

Module context_browse 

Source
Expand description

context_browse: expose the session transcript as real turn files.

§Meta-Harness filesystem-as-history (Phase B step 21)

Lee et al. (arXiv:2603.28052) demonstrate that agents given raw execution traces in a filesystem — retrievable via the grep / cat tools they already have — outperform agents given lossy summaries by +15 accuracy points on text classification (their Table 3). The ablation is blunt: scores-only 34.6 median, scores + summary 34.9 (essentially unchanged), full traces 50.0. Summaries “may even hurt by compressing away diagnostically useful details”.

This tool gives the agent the same primitive over its own past turns. Every entry in Session::messages is materialized as a file under the workspace data dir:

.codetether-agent/history/<session-id>/turn-NNNN-<role>.md

The agent’s existing Shell / Read / Grep tools can browse those files directly after this tool materializes them; this tool is the list + locate layer on top of that directory.

§What it does

  • list_turns (default): returns the canonical paths for every turn in the current session’s history, one per line.
  • show_turn: returns the text body of a single turn by index.

For a minimal first cut we surface the transcript from memory via Session::load — the disk format already matches what the agent would want to grep over. A future commit wires the same namespace to the MinIO-backed pointer resolver for long-horizon archives.

§Invariants

  • Read-only. This tool never mutates history.
  • Paths are stable: given an immutable session.messages, a path refers to the same turn across runs.

§Examples

use std::path::Path;

use codetether_agent::tool::context_browse::{ContextBrowseAction, format_turn_path, parse_browse_action};
use serde_json::json;

assert_eq!(
    format_turn_path(Path::new("/tmp/history/abc-123"), 7, "user"),
    Path::new("/tmp/history/abc-123/turn-0007-user.md"),
);

let action = parse_browse_action(&json!({})).unwrap();
assert!(matches!(action, ContextBrowseAction::ListTurns));

let action = parse_browse_action(&json!({"action": "show_turn", "turn": 3})).unwrap();
assert!(matches!(action, ContextBrowseAction::ShowTurn { turn: 3 }));

Structs§

ContextBrowseTool
Meta-Harness filesystem-as-history tool.

Enums§

ContextBrowseAction
Parsed form of the JSON args payload.

Functions§

format_turn_path
Produce the canonical materialized filesystem path for a turn.
parse_browse_action
Parse a tool-args Value into a typed ContextBrowseAction.