Skip to content

feat(model): add Anthropic adapter with pass-through model selection - #199

Merged
mindfn merged 2 commits into
mainfrom
codex/anthropic-adapter-model
Mar 5, 2026
Merged

feat(model): add Anthropic adapter with pass-through model selection#199
mindfn merged 2 commits into
mainfrom
codex/anthropic-adapter-model

Conversation

@mindfn

@mindfn mindfn commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a standalone AnthropicModelAdapter and register Anthropic as an independent provider path
  • support direct user-specified model names via Config.llm.model or ANTHROPIC_MODEL (no hardcoded alias mapping)
  • add Anthropic client example config, dependency wiring, unit tests, and OpenSpec/docs updates for this feature slice

Scope isolation

Verification

  • .venv/bin/pytest -q tests/unit/test_anthropic_model_adapter.py tests/unit/test_default_model_adapter_manager.py tests/unit/test_client_cli.py
    • result: 72 passed, 1 warning
  • openspec validate --changes "add-anthropic-model-adapter"
    • result: 12 passed, 0 failed

Notes

  • model naming is intentionally pass-through so new Anthropic model releases do not require code updates.

… selection

Introduce a new AnthropicModelAdapter and register it as an independent provider in the default adapter manager and model adapter exports.

Allow users to specify Anthropic model names directly via Config.llm.model or ANTHROPIC_MODEL instead of hardcoded alias mapping, so new Anthropic model releases do not require code changes.

Add Anthropic provider dependency and coverage: unit tests for adapter behavior and manager resolution, plus CLI provider integration checks.

Update docs and OpenSpec artifacts (design, proposal, tasks, feature evidence) and include a concrete client example config for Anthropic usage.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65bfd366b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +75 to +76
if self._extra:
params.update(self._extra)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep normalized max_tokens when merging extra params

generate() computes a validated integer max_tokens first (line 61), but params.update(self._extra) can overwrite it with raw config values. When llm.extra.max_tokens is null or a string (common in templated JSON/YAML), this sends max_tokens=None or a non-integer to Anthropic and the request fails at runtime. This negates _resolve_max_tokens fallback/normalization and can break production calls for otherwise valid configs.

Useful? React with 👍 / 👎.

Handle the review finding on Anthropic max_tokens merge semantics: keep normalized max_tokens from _resolve_max_tokens/options and prevent raw llm.extra.max_tokens from overwriting it during extra-param merge.

Add regression tests covering extra.max_tokens=None fallback (2048) and string normalization to int to prevent runtime request failures.

Update feature governance evidence for add-anthropic-model-adapter: mark status active, add Intent/Implementation/review links, and normalize Evidence sections to satisfy governance-intent/evidence-truth gate contracts.
@mindfn

mindfn commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review finding and pushed commit 756c5f5.

Changes made:

  • preserved normalized max_tokens in AnthropicModelAdapter.generate() by excluding raw extra.max_tokens from the late params.update(...) merge
  • added regression tests for extra.max_tokens=None fallback and string normalization behavior
  • updated docs/features/add-anthropic-model-adapter.md governance evidence blocks/links so governance-intent-gate and governance-evidence-truth both pass for this PR scope

@mindfn
mindfn merged commit 13704a5 into main Mar 5, 2026
11 checks passed
@mindfn
mindfn deleted the codex/anthropic-adapter-model branch March 5, 2026 08:46
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