Skip to content

Serialize model options for response JSON and SQLite logs - #1903

Open
lzywzh wants to merge 1 commit into
simonw:mainfrom
lzywzh:fix/json-safe-response-options
Open

lzywzh wants to merge 1 commit into
simonw:mainfrom
lzywzh:fix/json-safe-response-options

Conversation

@lzywzh

@lzywzh lzywzh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

When a plugin defines a datetime.date model option, json.dumps(response.to_dict()) and response.log_to_db(db) both raise TypeError because the options dictionary still contains the Python date object.

Serialize options in Pydantic's JSON mode for both persistence paths. The date is stored as an ISO string and restored by Response.from_dict(). Regression tests cover the JSON round trip and the value written to SQLite.

Validation on Windows with Python 3.13: the two regression tests fail on the base implementation and pass with the fix. Full suite: 1564 passed, 3 skipped, 6 xfailed, 27 xpassed. Black, Ruff, mypy, Cog, and package builds passed.

Implemented and tested with OpenAI Codex assistance.

This branch has not been deployed

No deployments
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