Skip to content

fix: improve error handling for tool call parsing - #447

Merged
tusharmath merged 1 commit into
mainfrom
feat/improve-tool-call-error-handling-focused
Mar 4, 2025
Merged

fix: improve error handling for tool call parsing#447
tusharmath merged 1 commit into
mainfrom
feat/improve-tool-call-error-handling-focused

Conversation

@tusharmath

Copy link
Copy Markdown
Collaborator

Improve Error Handling for Tool Call Parsing

Description

This PR enhances error handling during tool call parsing by providing more detailed context when errors occur. By capturing and including the specific tool call parts that failed to parse in the error message, it becomes easier to debug issues with tool call parsing.

Changes

  • Added anyhow::Context as AnyhowContext import to avoid name clash with the Context struct
  • Restructured the tool call parsing code to extract partial tool calls to a separate variable
  • Added detailed context to errors with with_context() to show which tool call parts failed to parse

Testing

All tests pass in the forge_domain crate, indicating that these changes do not affect existing functionality.

Motivation

When tool call parsing fails, the current error message doesn't provide enough information to diagnose the issue. This change adds more context to these errors, making it easier to debug when problems occur with partial tool calls.

Additional Context

This is a targeted, focused change that improves error reporting without changing the actual behavior of the code.

Adds more detailed error messages when tool call parsing fails by providing the
specific tool call parts that failed to parse. This will make debugging
easier when issues occur with partial tool call parsing.

The change uses anyhow::Context to add context to errors that might
occur during tool call parsing.
@tusharmath
tusharmath enabled auto-merge (squash) March 4, 2025 10:03
@tusharmath
tusharmath merged commit 1c18c4b into main Mar 4, 2025
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