Skip to content

fix: let /wt-diff tool.call throws reach the hook engine; test the subagent path - #4689

Merged
max-sixty merged 4 commits into
max-sixty:mainfrom
Yash2031v:fix-workflow-worktree-bug
Nov 5, 2026
Merged

max-sixty merged 4 commits into
max-sixty:mainfrom
Yash2031v:fix-workflow-worktree-bug

Conversation

@Yash2031v

@Yash2031v Yash2031v commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Refs #4656

Updates the /wt-diff hook's error handling to properly surface tool.call tracking failures to the engine.

  • Let throws reach the engine: Removed the try/catch, console.error, and .catch(...) passthrough. Tracking errors now propagate natively so the engine can catch them and accurately log hook skipped: threw <message>.
  • Tested the subagent path: Added a test to verify that a subagent edit correctly tracks its worktree and shows its diff.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does what #4656 asked for: errors are now logged instead of silently dropped, and the agentId path has a test. But Resolves #4656 will close that issue when this merges, and the change doesn't fix the missing worktree. It makes the next occurrence diagnosable and covers a path that already passes: the new test passes against the current handler as well. Neither explains why the background session missed the worktree. Unless the reproduction you mentioned on the issue showed this handler throwing, consider changing Resolves to Refs and retitling the PR (e.g. "Log tool.call tracking errors in /wt-diff and test the subagent path") so the bug stays open until it's pinned down. If the reproduction did show a throw here, posting the error and the setup on the issue would let the fix be checked against it.

@Yash2031v Yash2031v changed the title Fix missing subagent worktree in background sessions Log tool.call tracking errors in /wt-diff and test the subagent path Nov 4, 2026
@Yash2031v

Copy link
Copy Markdown
Contributor Author

You're absolutely right, thanks for the review! I've updated the PR title and changed Resolves to Refs so the issue remains open. This observability should help us catch the exact error trace when the missing worktree bug occurs again. #

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Thanks. With Refs, #4656 stays open until the cause is found. The new title matches what the change does, and CI is green at 065bcd8. If the missing worktree shows up again, please post the wt-diff: failed to track tool call line on the issue. That line will show whether this handler is involved.

worktrunk-bot
worktrunk-bot previously approved these changes Nov 4, 2026
@max-sixty

Copy link
Copy Markdown
Owner

Thanks — one change before merging: drop the new try/catch and console.error, and delete the .catch(($, e, next) => next(e)) line instead. A hooks module's console.error only reaches Claude Code's debug log, and the inner catch hides the throw from the engine, which already logs hook skipped: threw <message> when a hook throws with no .catch. The subagent-path test can stay.

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

@worktrunk-bot
worktrunk-bot dismissed their stale review November 5, 2026 05:48

max-sixty asked for a change before merge: drop the new try/catch and console.error, and remove the .catch(...) passthrough so the engine logs hook throws itself. The approval covered the try/catch version.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title and description still say the PR logs tool.call tracking errors. After the last push it no longer logs anything: it removes the .catch(($, e, next) => next(e)) that hid hook throws, so the engine reports them as hook skipped: threw <message>. The title becomes the squash commit message, so consider retitling it to something like "Let /wt-diff tool.call throws reach the hook engine; test the subagent path" and updating the first bullet to match.

@Yash2031v Yash2031v changed the title Log tool.call tracking errors in /wt-diff and test the subagent path fix: let /wt-diff tool.call throws reach the hook engine; test the subagent path Nov 5, 2026
@Yash2031v

Copy link
Copy Markdown
Contributor Author

ll requested changes are pushed! I've dropped the try/catch, console.error, and the .catch() passthrough so the engine can handle the throws natively. I've also updated the PR title and description to accurately reflect this behavior. Let me know if it's good to go

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Looks good from my side. The updated title and description now match the diff, my approval stands on the current head e40f04a, and CI is green there, including codecov/patch. A maintainer decides when to merge, so it now waits on their review.

@max-sixty
max-sixty merged commit c387233 into max-sixty:main Nov 5, 2026
37 checks passed
@max-sixty

Copy link
Copy Markdown
Owner

thanks a lot @Yash2031v !

@Yash2031v

Copy link
Copy Markdown
Contributor Author

Happy to help! Thanks for the review and merge. Let me know if there's anything else I can pick up. 🚀

max-sixty added a commit to max-sixty/tend that referenced this pull request Nov 21, 2026
Tend's review approved any PR with no defect. Submit said "If there are
no issues, approve with an empty body — silence means correct", and a
`code-review` finding needs a file, line and failure scenario, so a
correct change that wasn't worth its cost got an `APPROVE` unless
another check, such as the duplication check, turned its cost into a
finding. A repository overlay asking for a `COMMENT` on such changes
didn't override that default: worktrunk's reviews opened its
proportionality rule and approved anyway (max-sixty/worktrunk#4664,
max-sixty/worktrunk#4665, max-sixty/worktrunk#4666,
max-sixty/worktrunk#4670, max-sixty/worktrunk#4689,
max-sixty/worktrunk#4694).

Submit now says an `APPROVE` tells the maintainer the whole PR is worth
merging. Before one, including after a trivial increment, the session
says who loses what if the PR never merges and how they come to need it,
what it adds that later changes must keep working, and the cheapest
other way to get the benefit. It approves when the benefit pays for what
the PR adds and nothing materially cheaper exists; otherwise it posts a
`COMMENT` naming the cost or the cheaper way. On a self-authored PR,
where the review stays silent instead of approving, the same weighing
runs before that silence, so a correct bot PR that isn't worth merging
is raised as a concern, which Review's "carry its weight" bullet used to
ask for. That bullet goes, since Submit now owns the judgment. A
`COMMENT` that holds the verdict names its reason once, as a
merge-readiness hold already did, so a later push doesn't restate it,
and a re-targeted review that empties takes its verdict from Submit
instead of approving.

## Evidence

Eleven trajectory cases (`evals/cases/review-worth-*`) replay real
worktrunk PRs at their reviewed heads. On 20 Nov, with main (including
#1646 and #1712) merged in, this PR's review skill ran against main's,
three attempts per case per arm. On the four PRs that independent
reviewers judged not worth merging as written (max-sixty/worktrunk#4664,
max-sixty/worktrunk#4665, max-sixty/worktrunk#4666,
max-sixty/worktrunk#4694), these attempts held the verdict and named the
cost or a cheaper route:

| Executor | main | This PR |
| --- | --- | --- |
| Codex gpt-6.1-sol | 6 of 10 (2 attempts failed on model capacity) | 10
of 12 |
| Claude Opus 5.5 | 2 of 12 | 7 of 12 |

- Main's six Codex holds are on max-sixty/worktrunk#4666 and
max-sixty/worktrunk#4694, which the old text approved in all three
attempts on the 5 Nov base. Each review of max-sixty/worktrunk#4666
names the second cache as a copy of the existing cached `git remote
get-url` lookup, the kind of copy #1646 widened the duplication check to
flag; the reviews of max-sixty/worktrunk#4694 name the hand-written URL
parsing as more than the IPv6 fix needs. This PR also holds
max-sixty/worktrunk#4665 and max-sixty/worktrunk#4664 (2 of 3 each),
which main's text approved in every attempt that completed.
- On the PRs that should be approved (max-sixty/worktrunk#4334,
max-sixty/worktrunk#4469, max-sixty/worktrunk#4668,
max-sixty/worktrunk#4669, max-sixty/worktrunk#4680), Codex approved in
all 15 attempts on each arm. Claude, run on this PR's text only, held
max-sixty/worktrunk#4668 in 3 of 3, citing a `git rev-parse` per noted
directory on every pane refresh and a narrower fix, and held
max-sixty/worktrunk#4669 (2 of 3) and max-sixty/worktrunk#4680 (1 of 3)
over defects.
- On the 5 Nov base, not re-run: a standing hold that should survive a
test-only push stayed silent 6/6, a hold on a per-render cost stayed
held 6/6, and `review-landing-continuation` passed 3/3 on Codex.

## Costs

A trivial follow-up push now gets a whole-PR read.

> _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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants