Skip to content

Improve tool call APIs #363

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

Merged
merged 2 commits into from
Jul 14, 2025
Merged

Conversation

ryan-the-crayon
Copy link
Collaborator

@ryan-the-crayon ryan-the-crayon commented Jul 14, 2025

Make changes to the tool call status reporting API so that:

  • The LLM specific toolCallId is now available upon tool call request started (this is useful if one needs to use lmstudio-js as a OpenAI compatible endpoint proxy, as the toolCallId is required on the first fragment in OpenAI compatible endpoints.
  • The onToolCallRequestNameReceived and onToolCallRequestArgumentFragmentGenerated on both .act and .respond are now guaranteed to be called. If the underlying model doesn't support eager name reporting/arguments streaming, we will "fake" those events right before onToolCallRequestEnd is called.
  • Changed all the tool call related status report for .respond to add a callId parameter, as there might be multiple calls even within just one "round" of prediction. This is breaking change but we will not bump the major version because all the affects APIs were explicitly marked as experimental.

Fixes lmstudio-ai/lmstudio-bug-tracker#759 (LM Studio uses lmstudio.js internally)

@github-actions github-actions bot added the CLA signed Indicates if all contributors have signed the CLA label Jul 14, 2025
@yagil yagil requested a review from sergeichestakov July 14, 2025 20:01
@@ -424,6 +443,9 @@ export class LLMDynamicHandle extends DynamicHandle<
) {
let finished = false;
let firstTokenTriggered = false;
let currentCallId = -1;
Copy link
Member

Choose a reason for hiding this comment

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

nit: could consider not using -1 as magic number

@ryan-the-crayon ryan-the-crayon merged commit b69f37a into main Jul 14, 2025
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2025
@ryan-the-crayon ryan-the-crayon deleted the ryan/tool-call-api-improvements branch July 14, 2025 20:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA signed Indicates if all contributors have signed the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi tool calling from OpenAI API when stream=true got broken in 0.3.17 (works fine in 0.3.16) (still reproducible)
2 participants