Skip to content

docs(cli): describe the real smartapply model fallback (openai/gpt-4.1-mini) - #27

Merged
mikkel merged 2 commits into
mainfrom
docs/cli-smartapply-fallback
Oct 23, 2026
Merged

mikkel merged 2 commits into
mainfrom
docs/cli-smartapply-fallback

Conversation

@mikkel

@mikkel mikkel commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Docs only, in docs/cli.md. The CLI docs described the smartapply model fallback incorrectly. They said --applymodel / GPTDIFF_SMARTAPPLY_MODEL fall back to --model / GPTDIFF_MODEL, but they don't.

What the code does (smart_apply_patch in patchling/core.py, used by --apply)

  • Model: --applymodel, else GPTDIFF_SMARTAPPLY_MODEL if it is set and non-blank, else the hardcoded openai/gpt-4.1-mini. --model and GPTDIFF_MODEL are never used for the apply step. The existing --applymodel help text in core.py already says openai/gpt-4.1-mini.
  • API key: GPTDIFF_SMARTAPPLY_API_KEY, else GPTDIFF_LLM_API_KEY.
  • Base URL: GPTDIFF_SMARTAPPLY_BASE_URL, else GPTDIFF_LLM_BASE_URL, else https://nano-gpt.com/api/v1/.
  • When the model is called: every file in the diff goes to the model, with no deterministic first pass in the CLI path. The exception is deleted files (+++ /dev/null), which are removed directly. Each request uses --max_tokens.
  • Library smartapply() does not read the GPTDIFF_SMARTAPPLY_* variables. It uses its model argument, else GPTDIFF_MODEL, else DEFAULT_MODEL, and it tries a deterministic patch before calling the model. The docs now say this, so CLI and library behavior aren't confused.

openai/gpt-4.1-mini is on NanoGPT's public model list ($0.40 / $1.60 per 1M input / output tokens, 2026-10-21).

Verified locally (no network, no spend)

An offline probe ran smart_apply_patch with a stubbed apply call (probe-apply.out in the Ember pack):

Case Apply model Base URL
Nothing set (--model and GPTDIFF_MODEL set) openai/gpt-4.1-mini nano-gpt.com
Blank GPTDIFF_SMARTAPPLY_MODEL openai/gpt-4.1-mini nano-gpt.com
GPTDIFF_SMARTAPPLY_MODEL set that model nano-gpt.com
--applymodel and env both set the --applymodel value nano-gpt.com
GPTDIFF_SMARTAPPLY_BASE_URL set openai/gpt-4.1-mini the SMARTAPPLY URL
Only GPTDIFF_LLM_BASE_URL set openai/gpt-4.1-mini the LLM URL

In every case the deleted file was removed without a model call.

Other checks: pytest (offline, fake_tiktoken) gives 207 passed, 2 skipped, the same as main. mkdocs build --strict passes.

Notes

No code changes, version bump, tag, or publish.

mikkel added a commit that referenced this pull request Oct 22, 2026
…del-names

Resolve the SMARTAPPLY overlaps in docs/api.md and docs/cli.md in favor of
#27's CLI-only wording; keep #26's other model-name updates.
@mikkel
mikkel marked this pull request as ready for review October 23, 2026 00:28
@mikkel
mikkel merged commit d37f2f6 into main Oct 23, 2026
2 checks passed
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