Skip to content

Fix Pydantic JSON types in strict evidence serialization - #59

Open
ereinach wants to merge 1 commit into
Trampoline-AI:mainfrom
ereinach:codex/fix-pydantic-evidence-json
Open

Fix Pydantic JSON types in strict evidence serialization#59
ereinach wants to merge 1 commit into
Trampoline-AI:mainfrom
ereinach:codex/fix-pydantic-evidence-json

Conversation

@ereinach

Copy link
Copy Markdown
Contributor

Rationale

Typed Pydantic inputs containing JSON-specific values such as HttpUrl fail before RLM execution with Strict evidence serialization failed for run.started. This violates the established plain-data normalization and strict-evidence contract: supported Pydantic inputs must become JSON-serializable evidence.

Reproduction: emit a run.started evidence event whose inputs contain a Pydantic model with an HttpUrl. to_plain_data() used model_dump(mode="python"), which preserved the HttpUrl; the subsequent json.dumps() raised TypeError.

The root cause is that Pydantic v2 normalization selected Python mode even though its result is used for JSON transport and evidence.

Summary

  • Serialize Pydantic v2 models with model_dump(mode="json").
  • Add a behavior-level regression covering an HttpUrl nested in run inputs.
  • Preserve the existing fallback for model-dump-compatible objects that do not accept a mode.

Test Plan

  • uv run pytest tests/test_small_kernel.py::test_strict_evidence_serializes_pydantic_json_types -q
  • uv run pytest tests/test_small_kernel.py -m "not sbx" -q (101 passed, 4 optional SBX tests deselected)
  • uv run ruff check src/predict_rlm/serialization.py tests/test_small_kernel.py

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