Skip to content

fix(prompt): preserve string values in dataclass unions - #964

Open
ningyixi wants to merge 1 commit into
braintrustdata:mainfrom
ningyixi:fix/prompt-string-union-deserialization
Open

ningyixi wants to merge 1 commit into
braintrustdata:mainfrom
ningyixi:fix/prompt-string-union-deserialization

Conversation

@ningyixi

Copy link
Copy Markdown

Loading a chat prompt whose function_call is a string template raises AttributeError: 'str' object has no attribute 'items'. PromptMessage explicitly supports str | FunctionCall | None, but deep deserialization tries the dataclass branch for every non-None value. The same error makes a valid disk-cached prompt appear to be a cache miss.

Only attempt the nested dataclass conversion when the value is a dictionary. String templates and None retain their values, while dictionary function calls still become FunctionCall objects.

Validation on the pinned Python 3.14.7/Mise environment:

  • The direct prompt-loading regression and real compressed disk-cache round trip both fail before the fix; None and dictionary controls pass.
  • Focused cache/serialization checks: 29 passed.
  • Full test_core nox session: 1,093 passed, 106 skipped, 12 expected failures, with VCR replay only.
  • Required full make fixup passes, including Ruff, formatting, Codespell and repository consistency hooks. Targeted Pylint passes with the repository's --errors-only setting.

Implementation and local validation by OpenAI Codex.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T04:50:35.510729Z d829051 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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