Skip to content

fix(streaming): keep tool call name when later deltas send an empty name - #465

Open
Guezli wants to merge 1 commit into
nextcloud:mainfrom
Guezli:fix/streaming-empty-tool-name
Open

Guezli wants to merge 1 commit into
nextcloud:mainfrom
Guezli:fix/streaming-empty-tool-name

Conversation

@Guezli

@Guezli Guezli commented Nov 11, 2026 •

Copy link
Copy Markdown

Fixes #461

Some OpenAI-compatible providers (seen with Mistral, https://api.eu.mistral.ai/v1) send the function name only in the first streamed tool call delta and repeat it as "name": "" in every later delta. StreamingService::mergeToolCalls() assigned the name from every delta, so the empty string overwrote the real one and the Context Agent received tool calls without a name.

This change ignores an empty name in a delta. A non-empty name still overwrites as before, so behaviour with OpenAI (which omits name in later deltas) is unchanged.

Tests: added testEmptyToolNameInLaterDeltaDoesNotOverwriteTheName to tests/unit/Service/StreamingServiceTest.php. It fails without the fix ('name' => '') and passes with it. Also verified on a Nextcloud 35.0.2 instance with Context Agent 2.11.0: the agent then recognises schedule_event with the correct arguments.

AI disclosure: The fix, the test and this description were drafted with Claude Code (Claude Opus 5.5). I reviewed the change and tested it on a live Nextcloud 35.0.2 instance with Context Agent 2.11.0.

@edward-ly edward-ly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, sorry for the delay, but it looks great, thanks so much!

@edward-ly
edward-ly force-pushed the fix/streaming-empty-tool-name branch from 89e6e5d to 3b7ae07 Compare November 23, 2026 23:08
@edward-ly
edward-ly enabled auto-merge November 23, 2026 23:09
@edward-ly
edward-ly disabled auto-merge November 23, 2026 23:11

@edward-ly edward-ly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, the CI tests are now failing due to some other recent changes that have been merged. Would you be able to take a look and fix them really quickly?

@Guezli
Guezli requested a review from edward-ly November 24, 2026 06:05
@Guezli

Guezli commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the review! The failure came from #458, which added a required ContentChunkParserService argument to StreamingService. The new test still constructed it with only $l10n. Fixed in 9ffbcd3, which passes the parser like the other tests. Could you approve the workflows so CI can run?

@edward-ly edward-ly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! By the way, since this is your first contribution here at Nextcloud, I just wanna remind you to check out our AI policy and contribution policy in case you haven't seen them already. Two last changes I require (both merely administrative):

  1. Squash both commits into one (I'm not sure if it makes sense to keep the fix commit separately).
  2. Add an Assisted-by: trailer to the commit as detailed in our AI policy.

@Guezli
Guezli force-pushed the fix/streaming-empty-tool-name branch from 9ffbcd3 to e29c367 Compare November 24, 2026 07:46
Mistral and possibly other OpenAI-compatible providers repeat
"name": "" in every tool call delta after the first one. The empty
string overwrote the name received earlier, so the assembled tool call
had no function name.

Fixes nextcloud#461

Signed-off-by: Michael Tièche <115039460+Guezli@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-opus-5-5
@Guezli
Guezli force-pushed the fix/streaming-empty-tool-name branch from e29c367 to 0a25ea6 Compare November 24, 2026 07:47
@Guezli

Guezli commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the pointers! I squashed both commits into one and added the Assisted-by: trailer. I also replaced the agent-added sign-off with my own, and updated the PR description with an AI disclosure. Could you approve the workflows again?

Please excuse my English, it is not my first language. If anything is unclear, just let me know.

Assisted by ClaudeCode:claude-opus-5-5

@Guezli
Guezli requested a review from edward-ly November 24, 2026 07:54

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming tool calls lose the function name with Mistral (empty "name" in later deltas overwrites it)

2 participants