Skip to content

feat(infra): enable Claude/Anthropic in the gateway with agent-default alias (ADR 09)#131

Merged
JustAGhosT merged 1 commit into
devfrom
feat/anthropic-agent-default
Jul 3, 2026
Merged

feat(infra): enable Claude/Anthropic in the gateway with agent-default alias (ADR 09)#131
JustAGhosT merged 1 commit into
devfrom
feat/anthropic-agent-default

Conversation

@JustAGhosT

@JustAGhosT JustAGhosT commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What & why

Enables Claude/Anthropic in the LiteLLM gateway so non-interactive CI agents can route Claude Code through Sluice with alias-based model selection, implementing ADR docs/architecture/09-claude-code-via-sluice.md ("API-key billing = through Sluice"). Interactive Max-subscription Claude Code use stays direct-Anthropic.

Mirrors the existing multi-provider extra_providers pattern (ADR 11) exactly — no bespoke plumbing.

The agent-default alias

CI agents request model="agent-default". Sluice resolves it to a concrete Claude model so it can be re-routed centrally without touching any workflow:

order target tier
1 (primary) anthropic/claude-haiku-4-5 cheap
fallback anthropic/claude-sonnet-4-6 mid
fallback premium (Azure gpt-4o) always-present floor

Fallback chain: agent-default → claude-sonnet-4-6 → premium. Emitted whenever the Anthropic provider is active (independent of the Groq/Gemini/etc. has_any_extra chains).

Changes

  • infra/modules/sluice_aca/main.tfhas_anthropic gate + anthropic_models (concrete claude-haiku-4-5 / claude-sonnet-4-6 + the agent-default group with per-tier order), concatenated into litellm_model_list; new anthropic_fallbacks chain concatenated into fallbacks.
  • Secret wiring — reuses the generic extra_providers path: an anthropic entry auto-creates the provider-anthropic-key KV secret and injects the LITELLM_ANTHROPIC_API_KEY env var on the container (identical mechanism to GROQ_API_KEY). No new variable or dynamic block needed.
  • Provider activationdeploy.yaml + deploy-environment.yaml: read an ANTHROPIC_API_KEY GitHub environment secret and fold it into TF_VAR_extra_providers with env_name = LITELLM_ANTHROPIC_API_KEY. Absent key ⇒ provider stays inactive, plan unaffected.
  • scripts/keys.yaml — new dedicated mystira-ci virtual key allow-listing agent-default + the Claude models. (Kept separate from the interactive claude-code-cli key, which stays on the Max subscription.)
  • infra/env/prod/terraform.tfvars — documented the anthropic extra_providers example.
  • ADR 09 — Status flipped Open → Accepted (2026-07-03); operator go-live steps updated to the real extra_providers flow.

⚠️ python scripts/manage_keys.py apply must run after deploy to apply the mystira-ci allow-list on the running proxy.

Guardrails run

  • terraform fmt -recursive: clean (no changes).
  • terraform validate on infra/modules/sluice_aca: passes.
  • No plan/apply run against any environment (PR only).
  • keys.yaml + both workflow YAMLs validated as parseable.

Operator: the ONE step to go live

Place the Anthropic Console API key so Terraform can pick it up, then deploy + apply keys. Preferred (matches every other provider):

  • Set ANTHROPIC_API_KEY as a prod GitHub environment secret — the deploy workflow folds it into TF_VAR_extra_providers, and Terraform then creates the provider-anthropic-key KV secret and mounts LITELLM_ANTHROPIC_API_KEY.

Direct-KV alternative (per ADR-09 runbook convention), only if wiring TF_VAR_extra_providers from KV rather than a GitHub secret:

az keyvault secret set --vault-name pvc-prod-sluice-kv --name anthropic-api-key --value <key>

Then: run the deploy workflow, and python scripts/manage_keys.py apply.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for an additional Anthropic/Claude provider in the deployment flow.
    • Enabled a new agent-default model route for non-interactive CI use.
  • Bug Fixes

    • Improved fallback behavior so model selection can degrade more smoothly across supported providers.
  • Documentation

    • Updated architecture guidance to reflect the approved Claude routing approach and setup steps.
    • Added an example configuration for the new provider in production settings.

… (ADR 09)

Enable Anthropic/Claude in the LiteLLM gateway so non-interactive CI agents
can route Claude Code through Sluice on API-key billing, per ADR 09
("API-key billing = through Sluice").

- model_list: add anthropic_models (claude-haiku-4-5 cheap tier,
  claude-sonnet-4-6 mid tier) plus an `agent-default` alias group mapping to
  the cheap tier as primary (order 1), degrading to the mid tier then Azure
  `premium` via a new fallback chain. Gated on has_anthropic; concatenated
  into litellm_model_list.
- Secret wiring reuses the existing extra_providers path: an `anthropic`
  entry creates the provider-anthropic-key KV secret and injects the
  LITELLM_ANTHROPIC_API_KEY env var on the container — no bespoke wiring.
- Provider activation: deploy.yaml + deploy-environment.yaml read an
  ANTHROPIC_API_KEY GitHub secret and fold it into TF_VAR_extra_providers as
  env_name LITELLM_ANTHROPIC_API_KEY; absent key => provider stays inactive.
- keys.yaml: add a dedicated mystira-ci virtual key allow-listing
  agent-default + the Claude models (interactive claude-code-cli stays
  direct-Anthropic on the Max subscription).
- ADR 09 flipped to Accepted (2026-07-03); operator go-live steps updated to
  the real extra_providers flow.

terraform fmt: clean. terraform validate: passes.
Requires `python scripts/manage_keys.py apply` after deploy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 3, 2026 12:28
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds Anthropic model provider support to Sluice's routing infrastructure. It wires an optional ANTHROPIC_API_KEY through GitHub Actions deploy workflows into Terraform's extra_providers, extends the LiteLLM module with Anthropic models and an agent-default fallback chain, adds a mystira-ci allowlisted key, and updates architecture documentation to reflect the implemented state.

Changes

Anthropic provider integration

Layer / File(s) Summary
LiteLLM model list and fallback chain for Anthropic
infra/modules/sluice_aca/main.tf, infra/env/prod/terraform.tfvars
Adds has_anthropic/anthropic_models locals defining Claude entries and an agent-default alias with Haiku-primary/Sonnet-fallback ordering, merges them into the model list, combines extra-provider and Anthropic fallback chains into combined_fallbacks used for litellm_settings_raw.fallbacks, and documents a commented example in tfvars.
Workflow secret propagation for ANTHROPIC_API_KEY
.github/workflows/deploy-environment.yaml, .github/workflows/deploy.yaml
Adds ANTHROPIC_API_KEY as an optional secret/env var, conditionally injects an anthropic entry into TF_VAR_extra_providers mapped to LITELLM_ANTHROPIC_API_KEY, and forwards the secret from deploy-prod into the reusable deploy-environment workflow.
CI key allowlist for agent-default
scripts/keys.yaml
Adds a mystira-ci key with budget/rate limits, a model allowlist including agent-default, and CI metadata.
Architecture documentation update
docs/architecture/09-claude-code-via-sluice.md
Updates the ADR status to accepted, documents implemented wiring details, and rewrites the operator runbook to reflect the shipped implementation and remaining setup steps.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeployWorkflow as deploy.yaml
  participant DeployEnvWorkflow as deploy-environment.yaml
  participant Terraform as Terraform (main.tf)
  participant LiteLLM as LiteLLM Config

  DeployWorkflow->>DeployWorkflow: Read ANTHROPIC_API_KEY secret
  DeployWorkflow->>DeployWorkflow: Set TF_VAR_extra_providers.anthropic
  DeployWorkflow->>DeployEnvWorkflow: Forward ANTHROPIC_API_KEY (deploy-prod)
  DeployEnvWorkflow->>Terraform: Apply TF_VAR_extra_providers
  Terraform->>LiteLLM: Render anthropic_models + agent-default fallback chain
  LiteLLM->>LiteLLM: Resolve agent-default via combined_fallbacks
Loading

Compact metadata

  • Related issues: Not specified in the provided changes.
  • Related PRs: Not specified in the provided changes.
  • Suggested labels: infra, ci, documentation
  • Suggested reviewers: Not specified in the provided changes.

Poem
A rabbit hops through YAML fields so wide,
Anthropic keys now safely stowed inside.
From Haiku's speed to Sonnet's steady hand,
Fallbacks chain across the LiteLLM land.
agent-default — the CI's trusted guide. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling Claude/Anthropic support with the agent-default alias under ADR 09.
Description check ✅ Passed The description covers the summary, validation, and deployment notes, with only the risk/rollback and staging-toggle sections left incomplete.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/anthropic-agent-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

Enables Anthropic/Claude routing through the Sluice LiteLLM gateway for non-interactive CI agents via the agent-default alias, aligning implementation and operational guidance with ADR 09’s decision (accepted 2026-07-03).

Changes:

  • Adds an Anthropic provider gate in Terraform with Claude model entries plus an agent-default model group and dedicated fallback chain.
  • Wires ANTHROPIC_API_KEY through the existing extra_providers mechanism in deploy workflows to activate the provider without bespoke Terraform plumbing.
  • Introduces a dedicated mystira-ci virtual key allow-list and updates ADR 09 / prod tfvars documentation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/keys.yaml Adds mystira-ci virtual key configuration for CI agents and Claude model allow-listing.
infra/modules/sluice_aca/main.tf Adds Anthropic model definitions and agent-default fallback chain; composes fallbacks conditionally.
infra/env/prod/terraform.tfvars Documents how to configure the anthropic entry via extra_providers.
docs/architecture/09-claude-code-via-sluice.md Marks ADR 09 accepted and updates the implementation/setup guidance accordingly.
.github/workflows/deploy.yaml Adds Anthropic secret ingestion into TF_VAR_extra_providers and forwards the secret to the environment deploy workflow.
.github/workflows/deploy-environment.yaml Accepts ANTHROPIC_API_KEY as an optional workflow-call secret and folds it into TF_VAR_extra_providers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/keys.yaml
Comment on lines +75 to +80
- alias: mystira-ci
max_budget: 10
budget_duration: 7d
rpm_limit: 120
tpm_limit: 200000
models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, premium]
Comment on lines +166 to +167
CI consumers then set the two env vars from the per-consumer snippet below,
using `vkey-mystira-ci`, and request `model="agent-default"`.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/09-claude-code-via-sluice.md`:
- Around line 166-167: The runbook text mixes CI and interactive Claude Code
guidance, causing conflicting auth/routing instructions. Update the surrounding
section so the CI path in the relevant documentation uses the CI-specific key
and agent-default model, and move or rewrite the Claude Code CLI/Sluice example
under a separate interactive section. Use the existing “CI consumers” guidance
and the Claude Code CLI/Sluice example as the symbols to locate the conflicting
text.
- Around line 153-156: The fenced command block in the documentation is missing
a language identifier, which causes markdownlint violations. Update the shell
snippet in the affected markdown section to use a shell language tag such as
bash or sh, and keep the existing command content unchanged so the fenced block
is correctly labeled.

In `@scripts/keys.yaml`:
- Line 80: The mystira-ci allowlist in keys.yaml is missing cheap-long-context,
which breaks the auto fallback chain when LiteLLM resolves auto through
cheap-fast and cheap-reasoning. Update the models list for mystira-ci to include
cheap-long-context alongside the existing auto-related models so manage_keys.py
can pass a complete allowlist to /key/generate and allow the fallback path used
by infra/modules/sluice_aca/main.tf extra_fallbacks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6809fa7-5048-416c-b5f7-4d13edb2809b

📥 Commits

Reviewing files that changed from the base of the PR and between fa52fc4 and 8e98d04.

📒 Files selected for processing (6)
  • .github/workflows/deploy-environment.yaml
  • .github/workflows/deploy.yaml
  • docs/architecture/09-claude-code-via-sluice.md
  • infra/env/prod/terraform.tfvars
  • infra/modules/sluice_aca/main.tf
  • scripts/keys.yaml

Comment on lines +153 to +156
```
az keyvault secret set --vault-name pvc-prod-sluice-kv \
--name anthropic-api-key --value <key>
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Label the shell snippet.

The fenced command block at Line 153 is missing a language identifier, which violates the Markdown docs guideline and trips markdownlint. Add bash (or sh) to the fence.

Suggested fix
-```
+```bash

As per coding guidelines, docs/**/*.md: Include code blocks with language identifiers in Markdown documentation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
az keyvault secret set --vault-name pvc-prod-sluice-kv \
--name anthropic-api-key --value <key>
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 153-153: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/architecture/09-claude-code-via-sluice.md` around lines 153 - 156, The
fenced command block in the documentation is missing a language identifier,
which causes markdownlint violations. Update the shell snippet in the affected
markdown section to use a shell language tag such as bash or sh, and keep the
existing command content unchanged so the fenced block is correctly labeled.

Sources: Coding guidelines, Linters/SAST tools

Comment on lines +166 to +167
CI consumers then set the two env vars from the per-consumer snippet below,
using `vkey-mystira-ci`, and request `model="agent-default"`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Split the CI and interactive paths.

Line 166 says CI consumers should use vkey-mystira-ci, but the section below still hard-codes vkey-claude-code-cli and describes Claude Code CLI routing through Sluice. That conflicts with the decision above that interactive Max-backed Claude Code stays direct-Anthropic, and it will send operators to the wrong auth flow. Please separate the CI runbook from the interactive one, or swap the example key if this section is CI-only.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/architecture/09-claude-code-via-sluice.md` around lines 166 - 167, The
runbook text mixes CI and interactive Claude Code guidance, causing conflicting
auth/routing instructions. Update the surrounding section so the CI path in the
relevant documentation uses the CI-specific key and agent-default model, and
move or rewrite the Claude Code CLI/Sluice example under a separate interactive
section. Use the existing “CI consumers” guidance and the Claude Code CLI/Sluice
example as the symbols to locate the conflicting text.

Comment thread scripts/keys.yaml
budget_duration: 7d
rpm_limit: 120
tpm_limit: 200000
models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, premium]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Missing cheap-long-context in the mystira-ci allowlist breaks the auto fallback chain.

mystira-ci includes auto in its models list, but the auto fallback chain (infra/modules/sluice_aca/main.tf, extra_fallbacks) degrades auto → cheap-fast → cheap-reasoning → cheap-long-context → premium. Every other key with auto in this file also lists cheap-long-context; this one omits it. Since manage_keys.py sends models straight to LiteLLM's /key/generate as a key-level allowlist, a fallback landing on cheap-long-context for this key would be rejected.

🔧 Proposed fix
-    models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, premium]
+    models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, cheap-long-context, premium]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, premium]
models: [agent-default, claude-haiku-4-5, claude-sonnet-4-6, gpt-4o, text-embedding-3-large, auto, cheap-fast, cheap-reasoning, cheap-long-context, premium]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/keys.yaml` at line 80, The mystira-ci allowlist in keys.yaml is
missing cheap-long-context, which breaks the auto fallback chain when LiteLLM
resolves auto through cheap-fast and cheap-reasoning. Update the models list for
mystira-ci to include cheap-long-context alongside the existing auto-related
models so manage_keys.py can pass a complete allowlist to /key/generate and
allow the fallback path used by infra/modules/sluice_aca/main.tf
extra_fallbacks.

@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: 8e98d04bb2

ℹ️ 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 +152 to +156
- **Direct KV** (matches the runbook convention below):
```
az keyvault secret set --vault-name pvc-prod-sluice-kv \
--name anthropic-api-key --value <key>
```

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 Remove the unwired direct-KV go-live path

If an operator follows this Direct KV option, the deploy will still be Azure-only: the deploy workflows only populate TF_VAR_extra_providers from the GitHub ANTHROPIC_API_KEY secret, and Terraform only creates/mounts the provider-anthropic-key secret from that variable. Nothing in the inspected workflows reads anthropic-api-key, so local.has_anthropic remains false and the Claude models plus agent-default alias are not rendered; the runbook should not present this command as an equivalent go-live path unless the missing wiring is added.

Useful? React with 👍 / 👎.

@JustAGhosT JustAGhosT merged commit 50c3535 into dev Jul 3, 2026
2 checks passed
@JustAGhosT JustAGhosT deleted the feat/anthropic-agent-default branch July 3, 2026 12:52
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.

2 participants