Skip to content

Fix default model options when constructing Prompt directly - #1663

Merged
simonw merged 2 commits into
simonw:mainfrom
oodadoudou:codex/prompt-default-model-options
Sep 19, 2026
Merged

simonw merged 2 commits into
simonw:mainfrom
oodadoudou:codex/prompt-default-model-options

Conversation

@oodadoudou

@oodadoudou oodadoudou commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Directly constructing llm.Prompt("hello", model) leaves prompt.options as a dict. Providers that access option attributes then raise AttributeError; this also reproduces with the built-in OpenAI Responses provider on current main.

Use the model's Options() for the existing empty/default fallback. Explicit Options instances remain unchanged. Four regression cases exercise the public Prompt/Response path using the existing mocked HTTP response fixture: omitted options, None, an empty dict, and a populated Options instance.

Fixes #1028.

Validation (Python 3.12.9):

  • Before the fix, all three default-option cases fail on prompt.options.json_object; the explicit-options control passes. After the fix, all 13 options tests pass.
  • Full suite: 1,128 passed (18 warnings).
  • Black, Ruff, mypy and package build pass.
  • Local tests use httpx2-pytest==1.0.1: version 2.0.0 renames the httpx_mock fixture required by the existing suite. No dependency files changed.
  • Cog reports an existing version mismatch in unchanged docs/fragments.md (0.33) versus pyproject.toml (0.34), also present on the base commit 2f49eec9.

@simonw simonw added the bug Something isn't working label Sep 19, 2026
@simonw
simonw merged commit 508b4f8 into simonw:main Sep 19, 2026
1 check was pending
simonw added a commit that referenced this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When creating Prompt from python code, it doesn't get the correct options type

3 participants

⌂