Skip to content

UserWarning: Pydantic serializer warnings #916

Closed

Description

@xingyaoww
/home/xingyaow/Projects/agent-sdk/.venv/lib/python3.12/site-packages/pydantic/main.py:464: UserWarning: Pydantic serializer warnings:
  PydanticSerializationUnexpectedValue(Expected 10 fields but got 7: Expected `Message` - serialized value may not be as expected [field_name='message', input_value=Message(content="I'd be h...do this step by step."}), input_type=Message])
  PydanticSerializationUnexpectedValue(Expected `StreamingChoices` - serialized value may not be as expected [field_name='choices', input_value=Choices(finish_reason='to...ider_specific_fields={}), input_type=Choices])
  return self.__pydantic_serializer__.to_python(

shows up when we do uv run examples/01_standalone_sdk/01_hello_world.py

We should ignore all these warnings

Activity

  1. changed the title [-]: UserWarning: Pydantic serializer warnings[/-] [+]UserWarning: Pydantic serializer warnings[/+] on Oct 27, 2025
  2. added
    openhands
    on Oct 27, 2025
  3. openhands-ai commented on Oct 27, 2025

    @openhands-ai

    I'm on it! xingyaoww can track my progress at all-hands.dev

  4. added a commit that references this issue on Oct 27, 2025
    4a5567f
  5. openhands-ai commented on Oct 27, 2025

    @openhands-ai

    Summary

    I've successfully fixed issue #916 - Suppressed Pydantic serializer warnings from litellm.

    ✅ Changes Made:

    1. Modified openhands-sdk/openhands/sdk/llm/__init__.py:

      • Added warnings.filterwarnings("ignore", message="Pydantic serializer warnings") at module level to globally suppress these warnings
      • Added # noqa: E402 comments to all imports to satisfy linting requirements (imports must come after the warning filter)
    2. Created tests/sdk/llm/test_pydantic_warning_suppression.py:

      • Added a test to verify the warning filter is correctly registered
      • Test confirms no Pydantic serializer warnings appear during module operations

    ✅ Verification:

    • Before fix: Running uv run examples/01_standalone_sdk/01_hello_world.py showed UserWarning about "Pydantic serializer warnings"
    • After fix: No Pydantic warnings appear
    • All tests pass: 991 SDK tests passed successfully
    • Example runs cleanly: No more Pydantic serializer warnings in the output

    📦 Pull Request:

    Created draft PR #917: #917

    The PR is marked as draft and ready for review. All changes have been committed with proper co-authorship attribution and pushed to the openhands-workspace-73gj32i8 branch.

    View full conversation

  6. added 5 commits that reference this issue on Oct 27, 2025
    17b04a8
    90ac52b
    179d12b
    01148ab
    b8680df
  7. added a commit that references this issue on Oct 27, 2025
    fc87a83
  8. added a commit that references this issue on Nov 17, 2025
    819a878
  9. added a commit that references this issue on Jun 1, 2026
    b2e4aef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    openhands

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions