Skip to content

fix(core): call tool-level onEnd once on errors - #1539

Open
jeffierw wants to merge 1 commit into
VoltAgent:mainfrom
jeffierw:fix/tool-on-end-error-hook
Open

jeffierw wants to merge 1 commit into
VoltAgent:mainfrom
jeffierw:fix/tool-on-end-error-hook

Conversation

@jeffierw

@jeffierw jeffierw commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

  • remove the duplicated tool-level onEnd invocation in the tool execution error path
  • add a regression test for failing tools
  • add a patch changeset for @voltagent/core

Testing

  • pnpm --filter @voltagent/core exec vitest run src/agent/agent.spec.ts --reporter=default

With issues #1536


Summary by cubic

Fixes the tool-level onEnd hook being called twice when a tool execution fails in @voltagent/core.

Written for commit c16cc2a. Summary will update on new commits.

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tool-level onEnd hooks so they are called exactly once when tool execution fails.

@changeset-bot

changeset-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c16cc2a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When tool execution throws, the agent no longer calls the tool-level onEnd hook in the error path. A regression test covers the throwing tool, and a Changesets entry declares a patch release for @voltagent/core.

Changes: Tool Error Hook

Layer / File(s) Summary
Tool error handling
packages/core/src/agent/agent.ts, packages/core/src/agent/agent.spec.ts, .changeset/fix-tool-on-end-error-hook.md
The tool error path no longer calls the tool-level onEnd hook. The regression test checks the hook call details for a throwing tool. The Changesets entry declares a patch release.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: omeraplak

Merge Risk: Minimal · up to c16cc

This fix stops a tool's own onEnd hook from firing twice when a tool throws. The change is small and covered by a new regression test. The only remaining edge, a throwing agent-level end hook re-triggering the tool hook, was already there before this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: the tool-level onEnd hook is now called once on errors in @voltagent/core. The raw summary confirms the change removes a duplicate onEnd call from the tool error path. The …
Description check Passed The description follows the template's main parts. It has a Summary with the code change, a regression test, and a changeset. It gives a testing command and links issue #1536. It does not fill in the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: the tool-level onEnd hook is now called once on errors in @voltagent/core. The raw summary confirms the change removes a duplicate onEnd call from the tool error path. The title uses the conventional commit format and a specific scope.

Full details: Description check

Explanation

The description follows the template's main parts. It has a Summary with the code change, a regression test, and a changeset. It gives a testing command and links issue #1536. It does not fill in the checklist items, the 'current behavior' and 'new behavior' sections, or the reviewer notes. The 'fixes (issue)' line reads as a placeholder, and the issue is referenced as 'With issues #1536' instead of a closing keyword.

Resolution

Optional: state the current and new behavior under the matching headings. Tick the checklist items that apply, such as tests added and changeset added. Change 'With issues #1536' to 'fixes #1536' so the issue closes on merge.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09ca4981-43fe-413f-87ec-c58501e87d48
Commits

Reviewing files that changed from the base of the PR and between e9fc599 and c16cc2a.

Files selected for processing: 3

  • .changeset/fix-tool-on-end-error-hook.md
  • packages/core/src/agent/agent.spec.ts
  • packages/core/src/agent/agent.ts
Files with no reviewable changes: 1

  • packages/core/src/agent/agent.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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.

1 participant