Skip to main content

Module ctx_explore

Module ctx_explore 

Source
Expand description

ctx_explore — FastContext-style bounded, deterministic repo exploration.

Where crate::tools::ctx_compose is a single-shot composer that returns prose plus inlined symbol bodies, ctx_explore runs a bounded multi-turn loop and returns compact path:start-end citations (the FastContext idea, arXiv 2606.14066): the calling agent gets a map of where the answer lives at a fraction of the tokens, then reads only what it needs.

§Loop

  1. Query understanding — parse_task_hints → keywords + path hints.
  2. Lexical anchor — one broad BM25 search over the resident index.
  3. Structural expansion — bounded BFS over the static import/call graph, grounded in the lexical hit set (only files that actually match the query are followed). A turn that discovers no new files stops the loop early (coverage saturation).
  4. Symbol channel — exact AST definitions for each keyword (find_symbols).
  5. Selection — submodular greedy_max_coverage picks the minimal, non-redundant citation set that covers the query terms under a token budget.

§Determinism (#498)

The output is a pure function of (repo content, query, options). Only side-effect-free paths are used: the BM25 index and the static graph. It never writes session state and never records Hebbian co-access (cooccurrence::record_access) — those adaptive signals would make call N+1 differ from call N and are deliberately excluded from the byte-stable block.

Structs§

Citation
A single cited source span.
ExploreOptions
Caller-facing knobs. max_turns is clamped to a sane range; citation_only mirrors FastContext’s terse mode (emit only the <final_answer> block).
ExploreOutcome
Result of an exploration run.

Functions§

handle
Run a bounded, deterministic exploration for query.
parse_final_answer
Parse the path:start-end citations out of an explore answer. Reused by the eval harness to score the Explore arm. Tolerant of the optional trailing label and of text outside the <final_answer> block.