-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tool support for antropic streaming #14758
feat: add tool support for antropic streaming #14758
Conversation
Tested with 'Coder' and 'claude-3-5-sonnet-latest' on your branch with the following prompt: '@coder Implement the interface MCPServerManager in the same file (packages/ai-mcp/src/common/mcp-server-manager.ts). Don't ask me anything, jut do it.' got: |
hmm, the tool parameters were not extracted. I will debug. |
one tool had no schema defined as it doesn't need parameters, openai accepts undefined in that case, but anthropic doesn't. |
b1da705
to
0ebd8be
Compare
0ebd8be
to
e4ddde2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works very well for me, great work. I have only one comment/question
@@ -75,7 +75,11 @@ export class ToolCallPartRenderer implements ChatResponsePartRenderer<ToolCallCh | |||
let responseContent = response.result; | |||
try { | |||
if (response.result) { | |||
responseContent = JSON.stringify(JSON.parse(response.result), undefined, 2); | |||
let resultObject = response.result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do this conversion in the model implementation? Is this a corner case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I found out, MCP tools behave differently to our tools.
Our tools return the result usually as a string. But MCP returns it in the format that Anthropics API expect, which is an object with a content field which can be a string or an array of objects with content.
So the rendering completely exploded for me.
I can move the logic to the backend and make sure that the result written to the tool result object is a string.
What it does
This adds tool support to anthropic models when using streaming.
How to test
Follow-ups
Breaking changes
Attribution
Review checklist
Reminder for reviewers