[BUG] Background agent completion notification captures stale IDE selection context

Resolved 💬 2 comments Opened Mar 8, 2026 by mbelot007 Closed Apr 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When a background agent completes, the completion notification incorrectly includes the IDE's current text selection context as if it were part of the agent's result.

The notification shows:

  • ● Agent "Research concurrency patterns" completed
  • └ 🗐 Selected 1 lines from <file> in IntelliJ IDEA

The IDE selection context is being attached to the background agent's completion notification, even though the selection has nothing to do with the agent's work. It appears the notification is picking up whatever is currently selected in the connected IDE at the moment the agent finishes.

What Should Happen?

The background agent completion notification should only show the agent's name and completion status, no IDE selection context should be attached.

Expected output:
● Agent "Research concurrency patterns" completed

IDE selection context should only be captured and displayed when the user submits a new prompt, not when the system delivers a background agent notification.

Error Messages/Logs

Steps to Reproduce

  1. Connect Claude Code to an IDE (e.g., IntelliJ IDEA) via the IDE extension
  2. In Claude Code, launch a background agent (any agent with run_in_background: true)
  3. While the agent is running, select some text in a file in your IDE
  4. Wait for the background agent to complete
  5. Observe: the completion notification includes the IDE selection context (e.g., "Selected 1 lines from <file> in IntelliJ IDEA") attached to the notification

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.71

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗