Skip to content

codegraph_explore tells a fresh subagent that source was "already sent" to a different context #1620

Closed

Description

@AtkinsChang

Describe the bug

codegraph_explore's cross-call dedup replaces already-served source with an "Already sent earlier in this conversation … Use it from your context; do NOT Read this file" pointer. The already-sent record is kept per MCP connection, but one connection is not always one agent context:

  1. Subagents (Claude Code): subagents dispatch tool calls over the parent's MCP connection. A fresh subagent exploring a file the parent already received gets the pointer instead of the source — wrong on both counts: the source is not in its context, and it's told not to Read the file. There is no in-tool recovery; re-querying hits the same suppression, so the subagent falls back to Read/grep (or worse, answers without the source).
  2. Compaction: after the host compacts the conversation, the context no longer holds the already-sent source, but the server's record still does — subsequent explores return pointers to text that is gone until the connection restarts.

Reproduction

  1. In Claude Code, run any codegraph_explore that returns a file's source.
  2. Spawn a subagent (Task tool) and have it explore the same symbols.
  3. The subagent's very first explore returns > **Already sent earlier in this conversation:** … Do NOT Read this file.

Compaction variant: explore, /compact, explore the same symbols again — same pointer, source no longer in context.

Why it matters

The pointer is designed to be trusted ("that copy is still exact"). When it points at source the current context never had, the agent either reads the file anyway (defeating dedup and teaching it to distrust codegraph) or proceeds without source it believes it has.

Codex is unaffected on the subagent side (each thread gets its own MCP server process), but the compaction case applies to every host whose connection outlives a compact.

Activity

  1. colbymchenry commented on Sep 8, 2026

    @colbymchenry
    Owner

    Fix landed (Linux verified)

    PR: #1788
    Approach: landed upstream #1624 (@danusha2345) — make explore cross-call dedup opt-in via CODEGRAPH_EXPLORE_DEDUP=1. Default is now re-serve, so shared MCP connections (Claude Code subagents) and post-compaction contexts never get Already sent… Do NOT Read pointers to source they never held.

    Not used: draft #1621 (session buckets + installer hooks) — correct direction for keeping dedup on with host lifecycle hooks, but draft / no clean merge-base with current main; the opt-in default fixes both cases without that infrastructure.

    Linux fail → pass

    FAIL on main 7be699cd CODEGRAPH_EXPLORE_DEDUP unset → exploreDedupEnabled() === true
    PASS on PR head f9fe7e5a unset → false; npx vitest run __tests__/explore-cross-call-dedup.test.ts → 26 passed; tsc --noEmit clean

    Closing as fixed by #1788.

  2. added a commit that references this issue on Sep 8, 2026
    b8d46d1
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions