Repository navigation
Phase 6a: OpenAI provider adapter (offline, mocked) - #51
Merged
Merged
Conversation
Add an OpenAI Chat Completions provider on the official `openai` SDK: strict usage mapping to disjoint neutral counters (cached input and reasoning tokens handled separately; audio, predicted-output and inconsistent totals refused), key safety (only OPENAI_API_KEY, pinned base URL, OPENAI_BASE_URL refused, no retries), and a plain-JSON assistant turn so no replay codec is needed. OpenAI has no token-count endpoint, so the `Provider` protocol gains a `counts_tokens` flag (default True; mock/gemini/claude unchanged) and the OpenAI adapter declares it False. The loop then skips the pre-call token gate and relies on the existing post-call total check, and the estimate budgets the worst case at 2x the ceiling (one overshoot), read offline via `provider_counts_tokens` without instantiating the SDK (ADR 0023). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
…onfig Add the `openai` optional dependency (`dowbench[openai]`) and register the provider and sut_mapper entry points (ADR 0021). Add OPENAI_API_KEY to .env.example (noting OPENAI_BASE_URL is refused), a pricing.yaml entry for openai/gpt-6-luna (prices verified 2026-10-02), and configs/pilot-openai.yaml. The gpt-6-luna max_prompt_tokens is a flagged conservative placeholder pending confirmation of the short-context tier boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
Cover the OpenAI adapter with provider fakes (no real calls, no quota): usage mapping and its strict rejections, request/response mapping, finish reasons, replay round-trip, count_tokens returning None, setup errors, map_sut_response, and the 2x worst-case estimate. Add an agent-loop test for a non-counting provider running via the post-call ceiling, and update the packaging, rate-limit and retry fakes for the new counts_tokens flag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
Record the three OpenAI design decisions in ADR 0023 (usage mapping, no replay codec, post-call token ceiling), note the adapter under the changelog Unreleased section, and mark roadmap Phase 6 as adapter done (offline-tested; a real pilot is a separate authorized step). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
The owner confirmed the short-context tier boundary: 272000 tokens (the model's context window, verified on platform.openai.com/docs/models/gpt-6-luna on 2026-10-02). The previous 128000 was a flagged placeholder and is in fact the max_output_tokens, not the context window. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Phase 6a of the roadmap: a provider adapter so
dowbench runcan benchmark OpenAI chat models, the same way it already does Gemini and Anthropic. Everything here is offline and mocked — no real provider call is made. A real pilot smoke test is a separate, explicitly authorized step (Phase 6b).Design decisions are recorded in ADR 0023:
usageis mapped to the neutral disjoint counters:input = prompt − cached,cache_read = cached_tokens,reasoning = completion reasoning_tokens,output = completion − reasoning,cache_write = 0. Anything unpriceable fails loudly instead of being mispriced (unknown keys, audio tokens, accepted/rejected prediction tokens,total ≠ prompt + completion) — per ADR 0007.types.Content), so the existing cassette JSON round-trip reproduces it with no new codec (ADR 0015).Providerprotocol gains acounts_tokensflag (defaultTrue; mock/gemini/claude unchanged) and the OpenAI adapter declares itFalse. The loop then skips the pre-call token gate and relies on the existing post-call total check; the estimate budgets the worst case at 2× the ceiling (one possible overshoot per episode, like the bring-your-own-agent path in ADR 0012). Capability is read offline viaprovider_counts_tokenswithout instantiating the SDK.Key safety (ADR 0005): only
OPENAI_API_KEYis read, the base URL is pinned tohttps://api.openai.com/v1,OPENAI_BASE_URLis refused, andmax_retries=0. TheopenaiSDK is an optional dependency (dowbench[openai]), imported lazily so the module loads without it.Pricing for
gpt-6-lunaadded topricing.yaml(input $0.10/1M, cached input $0.01/1M, cache writes $0.125/1M, output $0.50/1M; verified 2026-10-02).Kind
Checklist
docs/adr/for any non-obvious decision (ADR 0023).max_prompt_tokensis explicitly flagged as a placeholder for you to confirm (see above).Verification
Offline sanity checks (no network):
dowbench estimate configs/pilot-openai.yaml→ worst case 320,000 tokens, $0.1600; "model calls: at most 70, checked after each call (no pre-call token count)" (the 2× factor applied).env -u OPENAI_API_KEY dowbench run configs/pilot-openai.yaml --budget-usd 1.0→cannot set up the run: OPENAI_API_KEY is not set; see .env.example.🤖 Generated with Claude Code
https://claude.ai/code/session_014wCFhM2gxQCfJYcm4Zu6z4
Generated by Claude Code