Skip to content

Suport for tool functions returning ToolResult image values#88

Merged
jph00 merged 4 commits intomainfrom
austinvhuang/multimodal-tool-support
Jul 18, 2025
Merged

Suport for tool functions returning ToolResult image values#88
jph00 merged 4 commits intomainfrom
austinvhuang/multimodal-tool-support

Conversation

@austinvhuang
Copy link
Contributor

@austinvhuang austinvhuang commented Jul 17, 2025

This PR is a prerequisite for AnswerDotAI/dialoghelper#21

This PR adds the definition of a special ToolResult type which carries a mime-type-like result_type metadata. In the case of result_type being str, it simply unwraps the .data and makes a tool result with .data as its string value.

In the future ToolResult will allow for other return types to be specially handled (eg media types need their own handling to be represented in the message history correctly), but for now this implementation is just a no-op on the current behavior with this ToolResult type instead of raw stringificaton for every tool function return value.

Eventually these responsibilities will all get get migrated to the litellm wrapper, but we implement this here now so that we can move ahead with upstream changes without breaking anything.

@gitnotebooks
Copy link

gitnotebooks bot commented Jul 17, 2025

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/claudette/pull/88

@austinvhuang austinvhuang marked this pull request as ready for review July 17, 2025 16:45
@austinvhuang austinvhuang requested a review from jph00 July 17, 2025 16:45
Copy link
Contributor

@jph00 jph00 left a comment

Choose a reason for hiding this comment

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

Thanks! Couple of minor suggestions to consider.

@jph00
Copy link
Contributor

jph00 commented Jul 17, 2025

@austinvhuang could you add a markdown cell above this describing what it is and what it's for? Quite a few folks outside AAI use Claudette too so I want to ensure we keep things well documented.

@austinvhuang austinvhuang changed the title ToolResult type + no-op passthru handling of ToolResult return values from tool functions Suport for tool functions returning ToolResult image values Jul 18, 2025
@austinvhuang
Copy link
Contributor Author

austinvhuang commented Jul 18, 2025

Updated this PR so it's no longer only handles the no-op case of ToolResult.

It now supports images and supports capture_screen from AnswerDotAI/dialoghelper#21 as a tool.

When mk_funcres / mk_toolres get a tool function return value of ToolResult, if the result_type is an image then it inserts the image tool result content here: https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/implement-tool-use#example-of-tool-result-with-images.

@jph00 jph00 merged commit f914994 into main Jul 18, 2025
@jph00 jph00 added the enhancement New feature or request label Jul 18, 2025
@austinvhuang austinvhuang added enhancement New feature or request and removed enhancement New feature or request labels Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants