Skip to content

Move the agent and extraction to gpt-6-luna - #4

Merged
aymanazeem merged 5 commits into
mainfrom
fix/models
Nov 30, 2026
Merged

aymanazeem merged 5 commits into
mainfrom
fix/models

Conversation

@aymanazeem

@aymanazeem aymanazeem commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Problem

OpenAI shut down gpt-4.1-nano, the extraction model, on 23 October 2026, and shuts down gpt-4.1-mini, the agent model, on 14 January 2027. The code also priced every prompt token at the plain input rate, although OpenAI bills the tokens it writes to and reads from its prompt cache at their own rates.

What changes

  • The agent and the extraction use gpt-6-luna, OpenAI's listed replacement for gpt-4.1-mini, with its reasoning off, temperature 0 and the standard service tier, on Chat Completions. These settings and the model prices live in src/config.py. docs/decisions.md gives the reasons and the alternatives.
  • Reported costs price cached tokens at their own rates, from the counts OpenAI returns. The extraction's dry-run estimate adds the reply's schema to each prompt, and prices input at the cache-write rate.
  • The extraction and the evaluation stop before the first request if the model has no listed price, and the setup check flags a model named in .env that has none.
  • The branch includes main up to Correct the report check count and the PDF reader timing #7, with this PR's README and documentation changes re-applied to the rewritten files.

Not yet checked against OpenAI's live API

I have no OpenAI credits at the moment, so this merges without a paid run. No request has gone to gpt-6-luna. So it isn't yet confirmed that OpenAI accepts these settings, that the reported costs match OpenAI's bill, or how accurate the extraction and the answers are. The README's limitations and the decision record say so. Once there are credits, the paid steps come first: make embed, make extract, the checks of AC2-093, AF1-236 and AF2-353 against the figures I read from their reports by hand, and make eval.

Verification

  • make test: 160 passed on Python 3.13, offline, with OpenAI replaced by a stand-in. CI runs the same tests on Python 3.11 and 3.14.
  • Dry runs: the setup check shows dry run on and the default models. make extract has nothing to do until the reports are embedded. python -m src.cli ask gives the fixed dry-run reply, and make eval wires all six questions. The embedding step is unchanged.
  • A new test pins the extraction estimate: the schema's tokens are added, and input is priced at the cache-write rate.
  • An independent agent reviewed the branch against OpenAI's pricing, deprecations, model, GPT-6 and prompt caching pages, and against the request bodies the code builds offline. It found no blocking issues, and confirmed offline that the cache writes for the 25 default reports cost less than a cent more than plain input. Its findings are fixed in dd22c3c: the README and the decision record now say plainly what hasn't been checked live, each model claim names the OpenAI page it comes from, the three projects to check by hand are described as outside the default sample, and the estimate counts the schema.
  • On 30 November I re-read the pricing page, the GPT-6 guide and the deployment checklist. The prices and settings in src/config.py match them.

OpenAI shut down gpt-4.1-nano, the extraction default, on 23 October
2026, and shuts down gpt-4.1-mini, the chat default, on 14 January
2027. Both now default to gpt-6-luna, OpenAI's listed replacement.

- gpt-6-luna is a reasoning model. Reasoning stays off, so it accepts
  temperature 0 and tool calls on the chat completions API.
- Prices cite OpenAI's pricing page. The retired models' prices are
  removed.
- The dry run estimate falls back to o200k_base, since tiktoken has no
  entry for gpt-6-luna.
- make check flags a model with no price, such as a retired model
  named in an older .env.
- Tests use the default models whatever .env names, and check the real
  requests through a local stub of the API.
- docs/decisions.md records this choice, the DuckDB lockdown and the
  cost restore on rebuild.
gpt-6-luna writes any prompt of 1,024 tokens or more to OpenAI's prompt
cache by default. It bills those tokens at 1.25 times the input rate, and
tokens read back from the cache at a tenth of it. The cost lines priced
every prompt token as plain input, so they under-reported new prompts.

- token_cost takes the cache read and write counts, and usage_cost prices
  the usage metadata a reply reports. Extraction and the evaluation sum
  the usage with LangChain's add_usage and price each reply as it
  arrives, so a model with no price stops a run after one call.
- The free extraction estimate is an upper bound at the cache write rate.
- The missing-price error says how to fix a stale model line in .env.
- docs/decisions.md explains temperature, OpenAI's two interfaces and the
  token encoding, describes the agent's job in full, links the caching
  guide and the deployment checklist, and corrects the price ratios.
- The README lists OpenAI's pricing and deprecations pages.
- Tests clear OPENAI_PROXY, which ChatOpenAI refuses next to a stub client.

133 tests pass offline with an empty tiktoken cache. The stub extraction
test fails on the previous code, which reported $0.0000075 instead of
$0.0000085.
- Both chat requests name OpenAI's standard service tier, whose prices
  MODEL_PRICES lists. Left unset, a request takes the tier set in the
  OpenAI project, and langchain-openai renames the cache counts of
  priority and flex replies, so the reported cost would be wrong.
- Extraction and the evaluation check the model's price before the first
  paid call, so an unpriced model costs nothing. Extraction prices the
  summed usage once, at the end.
- The free extraction figure is called an estimate, not a maximum. It
  leaves out the schema sent with each request and assumes one prompt
  length for every project.
- The stub reports cache reads as well as writes, the cost tests use
  literal dollar figures, and the evaluation test covers its cache line.
- docs/decisions.md records the service tier, explains prompts and the
  cache, and lists switching off cache writes as an alternative. The
  README cites the prompt caching guide.

135 tests pass offline with an empty tiktoken cache.
…e estimate

The README and the decision record now say that no request has gone to
gpt-6-luna, so neither OpenAI accepting the settings nor the reported costs
have been checked against the live API. The decision record attributes each
model claim to the OpenAI page it comes from, and notes that the newer Sol
models can't switch reasoning off. The three projects to check by hand are
described as outside the default sample.

The extraction dry run now adds the reply schema's tokens to each prompt,
and a test pins the estimate's token count and its cache-write pricing.
Temperature moves into src/config.py beside the other request settings.
@aymanazeem

Copy link
Copy Markdown
Owner Author

Evidence for dd22c3c: the checks job passed on Python 3.11 and 3.14 (run 46519704130), and the timing API reports 0 billable milliseconds on both jobs. Locally, make test gave 160 passed on Python 3.13. The dry runs of the setup check, make extract, python -m src.cli ask and make eval made no model call and behaved as described. An independent agent reviewed the branch and found no blocking issues, and its findings are fixed in dd22c3c. Not checked against OpenAI's live API: no request has gone to gpt-6-luna yet, as the description explains.

@aymanazeem
aymanazeem merged commit 96e346c into main Nov 30, 2026
2 checks passed
@aymanazeem
aymanazeem deleted the fix/models branch November 30, 2026 21:45
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