Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive support for tool calling functionality to the AI package, expanding its capabilities to handle OpenAI-style function calls in both streaming and non-streaming modes. The changes include extensive test infrastructure improvements, new API types, and detailed documentation.
Key changes:
- Implements OpenAI-style tool calling support with proper streaming and non-streaming handling
- Adds comprehensive test coverage for tool calling scenarios
- Refactors test infrastructure with better debugging and shared setup utilities
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ai/test/test-setup.ts | New shared test environment setup utility |
| packages/ai/test/mockHttpServer.ts | Enhanced mock server with tool calling support and debug logging |
| packages/ai/test/globalSetup.ts | Added performance timing for test setup |
| packages/ai/test/core.test.ts | Refactored tests and added tool calling test cases |
| packages/ai/src/utils.ts | Improved error message formatting |
| packages/ai/src/types.ts | Added tool definition types and streaming message types |
| packages/ai/src/core.ts | Updated to return AssistantMessage objects with tool call support |
| packages/ai/package.json | Added debug dependency |
| packages/ai/jest.config.js | Added test concurrency limits and timeout configuration |
| packages/ai/README.md | Added comprehensive tool calling documentation with examples |
Comments suppressed due to low confidence (1)
packages/ai/src/types.ts:110
- The property name 'args' is ambiguous and inconsistent with the function calling convention. Consider renaming to 'arguments' to match the OpenAI API standard used elsewhere in the codebase.
args?: Record<string, unknown> | null;
Even for Anthropic, we translate their tool calls into our own consistent format, but we were accidentally passing through a possible Anthropic style and documentating _that_.
anbuzin
approved these changes
Jul 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our previous methods only supported returning text that was generated by an assistant, but if you provide tools, we were never returning a rich enough object that would allow you to call the tools with the provided arguments.
This is a breaking change because instead of returning
string | null, we now return a wholeAssistantMessagefrom the main methods. See the updated README for additional details.