Skip to content

fix(chat): do not retry if we had chatdeltas or tooldeltas from backend#9244

Merged
mudler merged 4 commits intomasterfrom
fix/autoparser-go
Apr 6, 2026
Merged

fix(chat): do not retry if we had chatdeltas or tooldeltas from backend#9244
mudler merged 4 commits intomasterfrom
fix/autoparser-go

Conversation

@mudler
Copy link
Copy Markdown
Owner

@mudler mudler commented Apr 5, 2026

Description

This pull request addresses a critical bug in the retry logic for chat completions involving the C++ autoparser, ensuring that valid tool calls and content delivered via ChatDeltas are not discarded or retried unnecessarily. It introduces new regression tests, updates the backend mock to simulate autoparser behavior, and enhances the retry logic to properly recognize actionable ChatDelta content. This prevents excessive retries and output concatenation, improving both streaming and non-streaming chat endpoint behavior.

Bug fix: Retry logic for autoparser ChatDeltas

  • Enhanced the chat completion retry logic to check for actionable tool calls and content in ChatDeltas, preventing unnecessary retries when the C++ autoparser delivers results via ChatDeltas with an empty raw message. This fixes a bug where valid tool calls/content were ignored, causing up to 6 retries and concatenated output. [1] [2] [3] [4]

Testing: Regression tests for autoparser scenarios

  • Added comprehensive end-to-end tests that verify streaming and non-streaming chat completions correctly process tool calls and content from ChatDeltas, and do not retry or concatenate output unnecessarily.
  • Created a dedicated model config for autoparser tests, disabling grammar enforcement to ensure tool calls are driven by backend ChatDeltas.

Test infrastructure: Mock backend improvements

  • Updated the mock backend to simulate C++ autoparser behavior by emitting tool calls and content via ChatDeltas with an empty message, both for streaming and non-streaming endpoints. [1] [2]

Test utilities

  • Added necessary imports (e.g., encoding/json) to support new test logic for parsing streaming responses.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

mudler added 3 commits April 5, 2026 20:50
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the fix/autoparser-go branch 2 times, most recently from 8966fa6 to 8c43fd6 Compare April 6, 2026 07:12
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the fix/autoparser-go branch from 8c43fd6 to 313b5b0 Compare April 6, 2026 07:16
@mudler mudler merged commit 773489e into master Apr 6, 2026
43 checks passed
@mudler mudler deleted the fix/autoparser-go branch April 6, 2026 08:52
@mudler mudler added the bug Something isn't working label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant