Skip to content

/wt-diff doesn't list a worktree a Workflow agent edited in a background session #4656

Closed as not planned

Description

@max-sixty

What happens

In a Claude Code background session (Claude Code 2.1.310), a Workflow tool run started one agent with isolation: "worktree". Over a couple of hours that agent edited files in its own worktree with Edit and Write and committed them. Afterwards, /wt-diff in the same session didn't list the agent's worktree. The pane showed only the session's own worktree, which by then had no changes left. The work became visible only after the commit was cherry-picked into the session's own worktree.

Expected

The module's header says it notes "each directory Edit, Write or NotebookEdit wrote a file in, and each one a Bash call ran in or changed a file in, subagents' calls included", so the workflow agent's worktree should be listed.

What I checked

I ran a headless session (claude -p --plugin-dir) with a small probe plugin whose tool.call hook logs each call and appends to a $.state value, and whose turn.complete hook logs that value. The session ran one Workflow agent and one Agent-tool subagent, each with isolation: "worktree", in a scratch repository. Each agent wrote a file with Write and ran pwd with Bash.

  • tool.call fired for both agents' Write and Bash calls. Each carried the agent's agentId, $.session.cwd() returned the agent's worktree, and file_path pointed inside it.
  • The values those hooks appended to $.state were all present when the main loop's turn.complete read them.

So in that setup every input the module depends on arrives, and I haven't reproduced the miss outside the original session. That session differed in four ways:

  • It was a daemon-backed background session, not claude -p.
  • It loaded the installed marketplace copy of the plugin (5b3bf92), not --plugin-dir.
  • It ran for several hours, with a compaction before the workflow started.
  • The plugin's install record was updated twice during the session, to the same version.

Two things that would help pin it down

  • The tool.call hook ends in .catch(($, e, next) => next(e)), so any throw inside it drops the noted directories without a trace. Where the throw comes after the hook's own await next(e), it also calls next a second time. Logging the error there would make the next occurrence diagnosable.
  • tests/diff.test.tsx has no case where a tool.call carries an agentId, so the subagent and workflow-agent path isn't covered.

Seen on worktrunk 5b3bf92.

This was written by Claude Code on behalf of max-sixty

Activity

  1. worktrunk-bot commented on Nov 2, 2026

    @worktrunk-bot
    Collaborator

    I can't reproduce the missing worktree from the available evidence. The hook records Edit/Write paths for calls with an agentId; your headless probe observed those calls and shared state working in that setting, but it does not establish what happened in the daemon-backed session. I don't have a Claude Code runtime here to verify a change to that path, so I'm leaving the issue open rather than proposing an untested fix.

    Could you run the same probe in a daemon-backed background session with the installed plugin, and share one missed Write's agentId, file_path, and whether its directory survived into the probe's turn.complete state? That would establish whether the difference is in event delivery/state sharing or inside /wt-diff. The module's catch currently discards its error, so an error trace from that handler during a recurrence would further narrow the latter case.

  2. Yash2031v commented on Nov 4, 2026

    @Yash2031v
    Contributor

    I have reproduced the issue and implemented a fix for the error handling along with the missing test cases. I am raising a PR for this.

  3. max-sixty commented on Nov 21, 2026

    @max-sixty
    OwnerAuthor

    closing for now: couldn't reproduce, and since #4689 a throw in the hook gets logged as hook skipped: threw …. will reopen with that line if it recurs.

    This was written by Claude Code on behalf of max-sixty

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions