Skip to content

Conversation

@ian
Copy link
Owner

@ian ian commented Nov 17, 2025

Summary by cubic

Adds an onError hook to Agent for custom error handling. Errors are now centrally logged with the agent name, the callback is called, then the error is re-thrown.

  • New Features
    • Added AgentConfig.onError (sync or async) and centralized handleError in core.
    • Applied error handling to generateText and streamText paths.
    • Updated examples to show onError usage and added tests for sync/async handlers.
    • Added docs page: agent/error-handling.md with setup and integrations.

Written for commit 49339f5. Summary will update automatically on new commits.

@linear
Copy link

linear bot commented Nov 17, 2025

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ian ian merged commit 8486bcc into main Nov 17, 2025
12 of 13 checks passed
@ian ian deleted the hybrid-35-add-onerror-event branch November 17, 2025 15:17
Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="site/docs/pages/agent/error-handling.md">

<violation number="1" location="site/docs/pages/agent/error-handling.md:65">
The docs claim tool executions are automatically caught, but the core tool adapter just awaits tool.execute without a try/catch, so those errors still propagate. Please reword to note that each tool must handle its own failures.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR


### Tool Execution Errors

Errors from tool execution are caught by individual tools, but you can add additional error handling:
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 17, 2025

Choose a reason for hiding this comment

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

The docs claim tool executions are automatically caught, but the core tool adapter just awaits tool.execute without a try/catch, so those errors still propagate. Please reword to note that each tool must handle its own failures.

Prompt for AI agents
Address the following comment on site/docs/pages/agent/error-handling.md at line 65:

<comment>The docs claim tool executions are automatically caught, but the core tool adapter just awaits tool.execute without a try/catch, so those errors still propagate. Please reword to note that each tool must handle its own failures.</comment>

<file context>
@@ -0,0 +1,578 @@
+
+### Tool Execution Errors
+
+Errors from tool execution are caught by individual tools, but you can add additional error handling:
+
+```typescript
</file context>
Suggested change
Errors from tool execution are caught by individual tools, but you can add additional error handling:
Errors from tool execution need to be handled within each tool, so add your own error handling:
Fix with Cubic

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