GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): keep streamed tool calls with distinct ids apart by pcbeingused333 · Pull Request #1927 · MemMachine/MemMachine

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Purpose of the change

OpenAIChatCompletionsLanguageModel rebuilds streamed tool calls by keying deltas on tool_call.index only. Some OpenAI-compatible servers (the base_url is configurable) reuse index 0 for several tool calls, so their names and arguments were concatenated into one broken call (get_weatherget_time, with the arguments parsed as a list).

Description

Streamed tool call state is kept in arrival order. A delta is matched to the latest call with the same index, unless it carries an id different from that call's id, in which case it starts a new call. Normal streams (one index per call, id only in the first delta) behave as before, and results are still ordered by index.

Fixes/Closes

No linked issue.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test

test_generate_response_streamed_tool_calls_reusing_index streams two calls with ids call_a and call_b, both on index 0, and expects two separate calls.

Test Results: test_openai_chat_completions_language_model.py: the new test fails before the change (1 failed, 26 passed) and passes after it (27 passed, Python 3.12).

Checklist

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project (See STYLE_GUIDE.md)
  • I have performed a self-review of my own code
  • I have commented my code
  • My changes generate no new warnings
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

Further comments

This PR was prepared with the help of an AI coding assistant (Claude Code).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pcbeingused333
fix(server): keep streamed tool calls with distinct ids apart
1822241
Some OpenAI-compatible servers reuse the same index for several streamed
tool calls. Deltas were merged by index alone, which concatenated names and
arguments of different calls. Start a new tool call when a delta carries a
different id than the call already seen at that index.

Signed-off-by: Alex Castillo <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@pcbeingused333
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.