Skip to content

Match tool results' structure to that of prompts - #37

Merged
jspahrsummers merged 1 commit into
mainfrom
justin/structured-tool-results
Nov 6, 2024
Merged

Match tool results' structure to that of prompts#37
jspahrsummers merged 1 commit into
mainfrom
justin/structured-tool-results

Conversation

@jspahrsummers

@jspahrsummers jspahrsummers commented Nov 5, 2024

Copy link
Copy Markdown
Member

Tool results have suffered from being completely unstructured, which can make it hard for the client to integrate them into an LLM flow (for example—even just understanding whether they should be JSON stringified or treated as raw text).

I think this was not the case when we designed it originally, but now the Anthropic API requires structured tool results that include content blocks (like you would see during sampling).*

It's a bit of nice serendipity that we just aligned prompts with this format, and built in support for embedded resources. I see no reason not to do the same for tools too!

Unfortunately, this is a properly breaking change, so I'm revving the protocol version. However, servers and clients can still set and check the old toolResult field, for their own compatibility handling.

* OpenAI's API only supports string results AFAICT, but content blocks can be broken down into strings more easily than the reverse.

@jspahrsummers
jspahrsummers requested a review from dsp-ant November 5, 2024 16:44
@dsp-ant

dsp-ant commented Nov 5, 2024

Copy link
Copy Markdown
Member

Pains me to see the version bump. Oh well.

@dsp-ant dsp-ant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nicely spotted.

@jspahrsummers

Copy link
Copy Markdown
Member Author

h/t Florian 😅

@jspahrsummers
jspahrsummers merged commit 07ddc80 into main Nov 6, 2024
@jspahrsummers
jspahrsummers deleted the justin/structured-tool-results branch November 6, 2024 10:56
jspahrsummers added a commit that referenced this pull request Mar 12, 2025
Document `uv` as a prerequisite for the quickstart
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.

2 participants