Skip to content

fix: resolve Pydantic delta serialization warnings in agent streaming#1924

Merged
Vchen7629 merged 3 commits into
release-0.5.1from
chat-message-pydantic-field-warning-log-fix
Jun 22, 2026
Merged

fix: resolve Pydantic delta serialization warnings in agent streaming#1924
Vchen7629 merged 3 commits into
release-0.5.1from
chat-message-pydantic-field-warning-log-fix

Conversation

@Vchen7629

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1821. Resolves repeated PydanticSerializationUnexpectedValue warnings logged for every streamed chat chunk. Langflow's /response SSE always wraps text deltas as {"content": "..."} for every provider, but the openai SDK's response event models declare delta: str. When chunk.model_dump() runs, Pydantic's serializer checks delta against that str type, finds a dict, and logs a warning for every chunk which pollutes the openrag-backend logs

Changes

  • exclude delta from model_dump()'s serialization (which is what triggers the type-check warning), then reattach the raw, unvalidated delta value back onto the resulting dict. Output shape sent to the frontend/SDK is unchanged and only the noisy serializer warning is avoided.
  • Added a comment above my agent.py changes explaining why and when this workaround can be removed.
  • Added a simple regression unit test to verify that the pydantic warning isnt being raised and the fields to be expected

@Vchen7629 Vchen7629 requested a review from NishadA05 June 18, 2026 20:01
@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests labels Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3fd74ad3-a76c-4a82-a0fa-7fc708a218f7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Too big: expected number to be <=900000 at "reviews.tools.github-checks.timeout_ms"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chat-message-pydantic-field-warning-log-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 18, 2026
@github-actions github-actions Bot added the lgtm label Jun 22, 2026
@Vchen7629 Vchen7629 merged commit 26b28c6 into release-0.5.1 Jun 22, 2026
8 of 9 checks passed
@github-actions github-actions Bot deleted the chat-message-pydantic-field-warning-log-fix branch June 22, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. lgtm tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants