Skip to content

Conversation

@UhdyIndy
Copy link

@UhdyIndy UhdyIndy commented Jan 8, 2026

Problem

When some LLM providers (e.g., certain Ollama models) return None for reasoning_delta or response_delta in streaming chunks, the string concatenation in ChatGenerationResult.add_chunk() and _process_thinking_chunk() fails with:

TypeError: can only concatenate str (not 'NoneType') to str

This crash occurs during memory recall operations and other streaming workflows.

Solution

Normalize None values to empty strings ("") before any concatenation in:

  • add_chunk() - at the start, coerce incoming chunk values
  • _process_thinking_chunk() - guard the concatenation with or ""

Testing

  • Tested with dolphin-mixtral:org-uncensored via Ollama
  • Memory recall now completes without TypeError
  • No regressions in normal streaming behavior

Related

Fixes crashes observed when using local Ollama models that sometimes emit null reasoning deltas.

When some LLM providers return None for reasoning_delta or response_delta
in streaming chunks, the string concatenation in add_chunk() and
_process_thinking_chunk() would fail with:
  TypeError: can only concatenate str (not 'NoneType') to str

This fix normalizes None values to empty strings before concatenation,
preventing crashes during memory recall and other streaming operations.
Copilot AI review requested due to automatic review settings January 8, 2026 14:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a TypeError that occurs when LLM providers (such as certain Ollama models) return None values for reasoning_delta or response_delta in streaming chunks, which causes string concatenation to fail.

Key changes:

  • Added None-to-empty-string normalization at the entry point of add_chunk() method
  • Added defensive guards in _process_thinking_chunk() to handle potential None values during concatenation
  • Fixed a typo in a comment ("ned" → "need")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant