[Python] The manual Anthropic tool result flow can't mark a failed call with is_error

Open
#2,315 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with ToolCallData.execute and to_tool_result_message in the Anthropic integration, and the manual flow in docs/ai/integrations/anthropic.md. Compare how generate_tool_call_messages sets is_error with the manual path. The issue asks for a public API decision (return type or new argument), so confirm the approach with maintainers first. Done means a failed call can be marked is_error: true from the manual flow, with a test covering it.

Written by the indexing model from the issue text.

Description

Describe the bug

In the Anthropic integration, ToolCallData.execute returns only the tool result text. A tool result block built by hand with execute() and to_tool_result_message(), as shown in the Anthropic docs, therefore can't be marked with is_error when the function fails. After #2314 the block carries the error JSON, for example {"error": "date is in the past"}, but Anthropic's API is not told the call failed. generate_tool_call_messages sets is_error itself, so only the manual flow is affected.

To Reproduce

  1. Create a function whose body raises ValueError("date is in the past").
  2. Follow the manual flow in docs/ai/integrations/anthropic.md: result = tool_call.execute(client), then tool_call.to_tool_result_message(result).
  3. The block has the error JSON as its content but no is_error.

Expected behavior

The manual flow can mark a failed call with is_error: true, the same as generate_tool_call_messages.

System [please complete the following information]:

  • OS: any (unitycatalog-ai from main)

Additional context

Raised while fixing #2314. Changing execute() to return more than a string, or adding an is_error argument to to_tool_result_message(), both change the public API, so it is left for a separate change.

Dominant language
Java
Stars
3.6k
Forks
706
Avg merge
3d 5h
Merged PRs (30d)
135

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unitycatalog/unitycatalog

All issues in unitycatalog/unitycatalog

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.