Skip to content

Stale tool results: new tool calls replay prior call's verbatim result (positional per-name recall) #884

Description

@MSB0095

Observed live in TUI session 2026-08-11 01:15-01:25 UTC, jcode v0.75.0 (5ae2385), branch master, cwd ~/.jcode/source/jcode.

Symptom

New tool calls intermittently return the verbatim previous result of an earlier call (including the old [tool timing: start=... finish=...] header). This makes e.g. bash cat file right after edit file show pre-edit content.

Minimal repro sequence from the session:

  1. bash: cat > /tmp/stale_test.txt << EOF\nline1 original\nEOF → fresh (call it R1)
  2. edit /tmp/stale_test.txt → success, shows updated line
  3. bash: cat /tmp/stale_test.txtreturns R1 verbatim (same timing header as Add auto-update system for release builds #1). read in the same batch returned the fresh file correctly.

Evidence that it is a dispatch-layer positional replay (not model/provider cache)

A "punch" batch of 5 parallel identical-name bash probes echo punch-N $(date +%s) returned:

  • slot1 → R1 (stale)
  • slots2-5 → fresh punch2..punch5

Then a different batch of 5 parallel bash greps (q1..q5, all distinct commands) returned [R1, punch2, punch3, punch4, punch5] — a strict positional 1:1 mapping onto the previous bash batch's results, two turns stale.

Same pattern for agentgrep: a grep "cache_control" + grep find batch both returned the first grep's result (same timing 01:17:04.343). A later read .git/HEAD returned the earlier read Cargo.toml payload (same timing 01:18:09.934). side_panel write with a corrected page_id re-returned the earlier page_id is required for write error verbatim.

Pattern

  • Replay is per tool name, keyed by ordinal call position within the batch, persisting across model turns.
  • When the previous same-tool batch had N results, a later M-call batch replays positions 0..min(N,M); positions beyond N came back fresh in the same batch.
  • Errors replay identically, so the store captures fully-rendered result objects, not just stdout.
  • edit, write, todo, debug_socket, mcp__github__* appeared fresh throughout — so the bug is in how built-in parallel tool results are stored/retrieved, not in the whole pipeline.

Where to look

Per-name per-positional result buffer (Vec keyed by call index?) that is not cleared or not fully overwritten when the next turn's batch for that tool is smaller, or a "reuse result" fast-path keyed by (name, position) instead of tool_use id. Suspicious areas: tool dispatch batching in crates/jcode-agent-runtime, result assembly into API messages, and any memoization around tool_result_tag / BatchSubResult (crates/jcode-message-types, crates/jcode-tui/ui_tools/batch.rs).

Full chronological table is in STALE_BUG_EVIDENCE.md at the repo root of the session working copy.

Environment

  • OS: linux x86_64, HP i7-1165G7, 7.4 GiB
  • Shared-server build channel was the active daemon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: likelyProbably hands-off: clearly worth fixing, agent can do it, minor judgment needed.bugSomething isn't workingpriority: highP1 - important bug or impactful feature, fix soontriage: fixed-pending-releaseFixed in code/committed; will close automatically on next releasetriage: reproducibleClear repro + clear fix path

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions