Your API integrations, invisibly mended.
Your dependencies didn't change. The API did. Your code keeps calling it the old way. darnit finds the exact lines, rewrites them, runs your tests, and opens the pull request.
npm install -g darnit
Or skip the install: npx darnit check. Needs Node 22.12 or newer.
| Rev | Description | Status |
|---|---|---|
| A | max_ on OpenAI chat completions | Superseded |
| B | max_rewritten by darnit | Tests passed |
Three outcomes, verbatim.
Every line below is darnit's own output. Pick one.
darnit checkLists every affected call site, with the vendor's own notice.
darnit fixRewrites them with rules proven in CI.
<your tests>Your build and tests decide. If either breaks, the files go back.
No change: the same file also calls anthropic.messages.create({ max_tokens: 1024 }). darnit leaves it alone. That one is correct.
This change also alters how replies are read, so a safe rewrite needs a person. darnit tells you where, and changes nothing.
Why you can trust the pull request
- Every rewrite is a rule proven in CI before it ships. Same rule, same result, in every repo.
- Checks your SDK version before touching anything. Too old: it stops and names the upgrade.
- Runs your build and tests, and puts the files back if either breaks.
- Lists what it couldn't fix as
needs a human: file:lineinstead of pretending. - One pull request per change. Never force-pushes, never pushes to your default branch.
darnit-sh/darnit-example, a small example repository. Every word below is darnit's.Rename max_tokens to max_completion_
darnit wants to merge darnit/openai-max-tokens-to-max-completion-tokens into main
Renames max_tokens to max_completion_tokens. OpenAI deprecated max_tokens on chat completions, and it doesn't work with o-series models. On reasoning models the new limit also counts reasoning tokens, so the same number can give a shorter visible answer.
Why
OpenAI announced this change on 2024-09-12: https://developers.openai.com/api/docs/api-reference/chat/create
chat/create max_tokens: 'This value is now deprecated in favor of max_completion_tokens, and is not compatible with o-series models' (verified 2026-08-03)
What changed
app/summarize.py
Verified
python3 -m pytest -qpassed
test output
. [100%] 1 passed in 0.00s
Not verified
- This change needs openai >= 1.45.0 (PyPI); darnit could not find the version this repository uses.
- No generated regression tests yet; the checks above are the repository's own.
- Request options built elsewhere and passed in as a variable are not followed.
- Repos passing max_tokens through a shared
config/optionsobject need the rename at the config source, not the call site
darnit 0.1.0, change record openai:2024-09-12:max-tokens-to-max-completion-tokens
What it covers today
Fixes 1 OpenAI change, reports more, watches weekly. Small on purpose: a change gets a rewrite only when the rewrite is proven.
| Vendor | Status | What that means |
|---|---|---|
| OpenAI | Supported | Change records and rewrites |
| Anthropic, Stripe, Twilio | Recognized | darnit init finds them; no change records yet |
Reads JavaScript, TypeScript and Python. Runs on macOS and Linux. Want one covered? Open an issue.
Try it on your repo.
npx darnit check
Read-only. It lists what it finds and changes nothing. Install for good with npm install -g darnit.