Skip to content

Epic: agents retrieve scoped evidence through bounded, efficient brain tools #3640

Open
5 of 6 issues completed

Description

@schlessera

Outcome

Agents can discover relevant documents and obtain bounded, correctly scoped evidence through the CLI, MCP and both first-party backends. The efficient retrieval path is easy to choose, retains source attribution and completeness information, and is qualified against the existing parallel-call workflow rather than an assumed sequential baseline.

Why now

A project-overview task naturally needs document dates, status evidence and selected recent sections. Individual reads can already run concurrently, and a repeated path may be a legitimate section follow-up after an outline. Nevertheless, per-call envelopes, hooks, journal observations and oversized responses can make broad retrieval expensive. Better discovery metadata, bounded multi-document reads and explicit context scope address different parts of that workflow.

The UI ambiguity is tracked separately in #3636. Diagnostic access and subagent rendering are #3637 and #3638. This epic owns retrieval behavior and its evidence, not those presentation/access features.

Shared context

Current source at inspected main:

Follow ROADMAP.md, docs/integration-contract.md, docs/decisions/provider-history.md, docs/decisions/module-mcp-tools.md and the shared-operation direction of #1341. #365 is the delivered predecessor, not unfinished work to reopen.

Primary research references: MCP filesystem multi-file reads, OpenAI parallel function calls, OpenAI latency guidance, and Anthropic tool-design guidance. These establish useful patterns, not measured brain-kit speedups.

Constraints and non-goals

  • Markdown remains authoritative and the index disposable. Use concrete shared operations behind thin CLI/MCP/backend adapters; add no extension seam, generic arbitrary-tool batch executor, daemon or provider migration.
  • Preserve legacy single-read output and the existing outline-threshold meaning. mcp: brain_read can return one section or stop at a token limit #383 explicitly deferred a default cap on old single-read calls; preserve that boundary. The later explicit mcp: bound the brain_graph result with a whole-edge cut like Pi's #3677 ruling separately approves a default cap on MCP brain_graph with its own breaking-contract treatment.
  • Bound file count, work and complete model-visible response size. Preserve per-path containment, provider masks, permission checks, cancellation, warning provenance and truthful partial results. Retrieval scope never grants new access.
  • Keep tool rosters and provider-facing history stable within a session. No retrospective transcript trimming, tool removal or mutation for apparent savings.
  • Do not claim that fewer tool invocations mean the same reduction in provider requests. Measure quality, actual request grouping, tokens, latency and costs separately. Fake providers prove runtime mechanics, not model choice or provider savings.
  • Use Odysseus fixtures and the pinned 2026-07-12 date. No private content, session identifiers, infrastructure or private-instance links enter public issues or committed evidence.

Breakdown

The native sub-issue list carries the work: first qualify the bounded-read contract and baseline; then deliver bounded multi-document/section reads if the result supports them. Richer paginated discovery and explicit context scope are independent implementation slices. Separate search and graph investigations decide whether their own aggregate operations are worthwhile; a documented no is a valid result for either investigation.

Track: Answer quality. Keep this epic in that track's scripts/sync-project.ts membership so native children inherit it.

Definition of done

  • Every child has a delivered outcome or an explicit evidence-backed disposition, with no unresolved scope hidden by closure.
  • Discovery exposes the facts needed to choose useful reads, and explicit context exclusions hold across canonical, retrieved and related content.
  • Bounded multi-read behavior is delivered consistently and documented, or an accepted no-go records why the existing parallel interface remains preferable.
  • Search and graph candidates have separate measured recommendations, without speculative production APIs being treated as required delivery.
  • Required contract, runtime, provider-history and mutation proof holds for shipped changes. Evaluation distinguishes source/host mechanics, real-model usability and provider-reported usage; it never infers savings from an attractive call count alone.

This epic is never coded directly and is not agent-ready. Priority p2 reflects the wanted, unscheduled retrieval outcome; no release milestone is assigned.

Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Verified the shared-operation anchors and six native children. Preserve separate investigation/implementation gates and epic-only readiness.

The 2026-11-09 maintainer ruling explicitly detaches #3677, #3678, #3679, #3680 and #3683; they remain open standalone follow-ups with their own labels/readiness. Current native membership has six children: #3641/#3642/#3643/#3645/#3646 are closed, and #3644 is the only open child. #3683 remains #3644’s actual blocker because its expansion output is required for the project-evidence criterion; losing epic membership does not satisfy that dependency. The separate #3689/#3695–#3697/#3711/#3712 handoff remains standalone. Close this epic only when #3644 is completed and the full definition of done holds. The earlier eleven-child preservation note is superseded by this explicit maintainer ruling, not by an automatic reparenting decision.

Triage 2026-11-08 at main 8752570331ffebdbb9233196412781f6cd71f3d9: Reconciled shipped retrieval surfaces and the actual native child inventory, preserving existing parents and the separate follow-up handoff. No retrieval/contract choice or runtime qualification is inferred.

Follow-up rulings — 2026-11-08

The maintainer has settled the graph/context follow-up choices; implementation and proof remain open in their now-standalone issues:

  • #3677: a default whole-edge graph cut, capped at 30,000 UTF-16 code units of the JSON result text including its envelope/counts/warnings/escaping. The structured copy is identical and is not separately capped; wire bytes can exceed the text cap. This is a ruled breaking default change, shipped before 1.0 in a minor with the authoritative MCP contract update and changeset.
  • #3678: one core query-layer maximum depth of 5, used by MCP and Pi. Both clamp below 1 to 1 and above 5 to 5; Pi's default remains 1. This is an additive widening for Pi/query, with the documented contract updates.
  • #3683: preserve unique-section expansion; for an unknown/ambiguous folded match, emit the whole merged chunk span in source order only if it fits the remaining per-hit and total budgets. Otherwise preserve the snippet with honest coverage. Scope, excluded-file no-open, monotonicity and whole-block cuts remain. A new coverage form, if required, needs an additive CONTRACT change. Rerun and explain retrieval-golden diffs.

The recorded graph/context rulings do not add those standalone deliverables back into this epic. #3644’s project-evidence check still waits for #3683’s implemented expansion and rerun; a recorded ruling is not a completed runtime repair. #3677/#3678 retain their own independent completion criteria.

Triage 2026-11-08 at main 57abb7b9151556ccf534eb5f81eaea0b1917cb46: Reconciled the concurrent graph/context rulings in this epic without claiming implementation, changing child membership or adding epic readiness.

Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Folded the later explicit detachment ruling into the active native inventory and completion scope. Preserved all standalone issues and #3644’s actual #3683 dependency; no attachment, reparenting, implementation or completion was performed by this correction.

Activity

  1. added
    type: featA new capability or a change in user-visible behaviour.
    area: corepackages/core: the brain CLI, indexer, hybrid search, config, taxonomy, skills.
    area: mcpThe stdio MCP server and its brain_* tools.
    area: backendsAgentBackend implementations and the seam they share.
    epicA tracking issue. The work lives in its sub-issues; this one is never coded directly.
    on Nov 6, 2026
  2. added
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    on Nov 8, 2026
  3. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Epic state, 2026-11-08

    Work runs through the integration branch epic/3640-bounded-retrieval. Child PRs merge into it, and the epic lands on main as one batch. Children stay open, referenced with Refs, until that landing.

  4. 3 remaining items

  5. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    2026-11-08 triage: the single-root retrieval follow-ups now belong natively to this epic: #3677 (MCP graph output bound), #3678 (shared graph depth bound), #3679 (missing indexed root warning), #3680 (safe MCP read errors), and #3683 (merged-section context evidence).

    #3679 and #3680 have complete independent briefs and are agent-ready. #3677 needs a cap/compatibility/unit ruling; #3678 needs a ruling reconciling the two currently documented caps; #3683 needs the exact scoped fixture plus the matching-section versus whole-span decision. Recommendations are not approvals. Their p2 rankings match this unscheduled epic. General index freshness #3681 and shared Pi file/command clipping units #3682 stay standalone with explicit scope reasons.

    The #3646 no-go report in #3670 is merged into the epic integration branch at 0ce2256, and is not yet on inspected main 1619741. It keeps parallel single-root calls and does not approve any new graph contract. Existing native children and their current claim comments remain in force; no assignment, milestone or closure changed. Independent ready fixes can proceed while the contract/evidence questions are resolved. Parent closure still requires the outcome and full definition of done after the integration reaches main.

  6. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Epic state, 2026-11-08 16:20 UTC

    All six children have merged into epic/3640-bounded-retrieval, each after its own passing ready-candidate proof against the epic base.

    Child Sub-PR Result
    #3641 #3674 Go: a distinct, bounded brain_read_many
    #3642 #3702 brain_read_many (MCP, Pi), brain read-many --json
    #3643 #3684 Paged brain_list with path_prefix, cursor and overview
    #3644 #3675 Explicit include/exclude scope for context assembly
    #3645 #3691 No-go: multi-query search
    #3646 #3670 No-go: multi-root link traversal

    The landing PR, #3721, is deferred. Its one fresh proof failed on a unit (3) timeout, and main is red now (incident #3734). The deferral comment on #3721 has the evidence and the steps to resume. Every child stays open until #3721 merges.

    #3644 will stay open even after the landing: its project-evidence criterion lost one fact to a section-expansion limitation, which #3683 tracks.

    Follow-ups filed: #3677–#3683, #3695–#3697, #3711 and #3712. The 0.45.0 milestone is set on every child, every sub-PR and #3721.

  7. added a commit that references this issue on Nov 8, 2026
  8. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Landed on main (2026-11-08): #3721 merged as 26b45cbeb, a merge commit, verified as an ancestor of origin/main.

    The batch got one retry on head a1170d194, at the maintainer's request after the first proof's unit (3) timeout. The retry ran under the integration lease after main turned green, and every selected job passed (run 42504484867).

    This epic stays open until #3644 closes. Follow-ups that are not children of this epic: #3677–#3683, #3689, #3695–#3697, #3711 and #3712.

  9. schlessera commented on Nov 9, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-09): detach #3677, #3678, #3679, #3680 and #3683 from this epic. They are single-root retrieval follow-ups that the 2026-11-08 landing note already said fall outside this epic's delivered scope. Each stays open, standalone, with its labels and readiness unchanged.

    Epic state after detaching: #3641, #3642, #3643, #3645 and #3646 are closed. #3644 (explicit path scope in context assembly) is the only open child. It is blocked by #3683, which keeps its place as #3644's blocker even though it is no longer a child. This epic closes when #3644 closes and the definition of done holds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: backendsAgentBackend implementations and the seam they share.area: corepackages/core: the brain CLI, indexer, hybrid search, config, taxonomy, skills.area: mcpThe stdio MCP server and its brain_* tools.epicA tracking issue. The work lives in its sub-issues; this one is never coded directly.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: featA new capability or a change in user-visible behaviour.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions