Skip to content

Fix tool and sub-agent state leaking between chats - #273

Merged
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
rschmukler:rs/fix-buffer-mutable-state
Jul 16, 2026
Merged

ericdallo merged 1 commit into
editor-code-assistant:masterfrom
rschmukler:rs/fix-buffer-mutable-state

Conversation

@rschmukler

Copy link
Copy Markdown
Contributor

What changed

Each chat now keeps its tool and sub-agent state separate.

Previously, several hash tables were marked as buffer-local but were initialized with shared mutable values. As a result, newly created chat buffers could still reference the same underlying state.

This affected:

  • Tool-call timers
  • Sub-agent routing
  • Sub-agent usage information
  • Tool preparation state
  • Expandable tool content

Why it only happened sometimes

The problem required a particular sequence of events:

  1. Two or more chats had to be open at the same time.
  2. One chat had to be running a tool or sub-agent.
  3. Another chat then had to finish, stop, reset, or clear its tool state.

Normal updates usually affected unique tool-call IDs, so they did not obviously interfere with other chats. The problem became visible when a chat cleared an entire shared hash table, which also removed state belonging to other chats.

This made the behavior appear intermittent, but it depended on the timing and order of activity across multiple chats.

Testing

Added a regression test that verifies finishing tool activity in one chat does not clear a sub-agent’s elapsed-time state in another chat.

Ensure finishing one chat cannot clear another chat's running subagent timer or related tool state.
@ericdallo
ericdallo merged commit 005fbd8 into editor-code-assistant:master Jul 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants