Skip to content

Fixes forwarding of authentication token for claude when using vLLM as backend#49

Merged
nezhar merged 1 commit into
mainfrom
extend-open-ll-auth
Mar 18, 2026
Merged

Fixes forwarding of authentication token for claude when using vLLM as backend#49
nezhar merged 1 commit into
mainfrom
extend-open-ll-auth

Conversation

@nezhar
Copy link
Copy Markdown
Collaborator

@nezhar nezhar commented Mar 18, 2026

Enhances the handling of environment variables for LLM agent specifications, particularly for the "claude" agent.

Summary by CodeRabbit

  • New Features

    • Enhanced environment variable configuration for agent setup, now supporting multiple authentication and model options for more flexible configuration.
  • Tests

    • Updated tests to validate new environment variable mappings and configurations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

Warning

Rate limit exceeded

@nezhar has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a2d57a6-bbc5-4b26-bde3-3998f2fb5f40

📥 Commits

Reviewing files that changed from the base of the PR and between 6cb1a54 and 9653806.

📒 Files selected for processing (5)
  • docs/llm.md
  • src/vibepod/commands/run.py
  • src/vibepod/core/agents.py
  • tests/test_agents.py
  • tests/test_run.py
📝 Walkthrough

Walkthrough

Enhances environment variable mapping for LLM agent configuration by extending llm_env_map to support multiple target variables. The type system now allows both string and list-of-string values. The run command logic is updated to expand and set environment variables when mappings contain lists. Claude agent spec is updated with multiple API key and model environment variable options.

Changes

Cohort / File(s) Summary
LLM Environment Variable Expansion
src/vibepod/commands/run.py
Modified to handle env_var as either a string or iterable; expands list values and sets each target environment variable using setdefault.
Agent Specification Updates
src/vibepod/core/agents.py
Extended llm_env_map type from dict[str, str] to `dict[str, str
Test Assertions
tests/test_agents.py, tests/test_run.py
Updated test expectations for Claude agent spec llm_env_map structure, including list-based api_key mappings and new model environment variable assertions. Added validation that new environment variables are injected when enabled and omitted when disabled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hop hop, environment variables now multiply,
One key maps to many, reaching for the sky,
Claude's API dancers in a synchronized line,
Default models flourish, configuration divine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main objective of enhancing authentication token forwarding for Claude when using vLLM as backend, which aligns with the core changes expanding llm_env_map to support multiple target environment variables including ANTHROPIC_AUTH_TOKEN.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch extend-open-ll-auth
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 18, 2026

Greptile Summary

This PR fixes authentication token forwarding for Claude Code when backed by a vLLM-compatible server (e.g., Ollama). It extends llm_env_map in the Claude AgentSpec to fan out a single LLM config key to multiple target environment variables, and updates the injection loop in run.py to handle both str and list[str] values.

Key changes:

  • api_key now maps to both ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN, fixing the case where the Claude SDK reads ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY for authentication.
  • model is now also mapped to ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_HAIKU_MODEL, ensuring all model-resolution paths in the Claude SDK point to the single vLLM-served model.
  • The llm_env_map type annotation in AgentSpec is updated from dict[str, str] to dict[str, str | list[str]] to reflect the new shape.
  • Tests and documentation are updated to match the new behaviour.
  • Minor gap: test_llm_empty_model_not_injected checks the three ANTHROPIC_DEFAULT_*_MODEL vars but omits an assertion for ANTHROPIC_MODEL itself.

Confidence Score: 5/5

  • Safe to merge; the logic change is minimal and well-tested with only a minor test coverage gap.
  • The core change (fan-out of a single LLM config key to multiple env vars) is small, isolated to one loop, and covered by integration tests. The type annotation change is accurate. The only finding is a missing assertion in one test, which does not affect runtime behaviour.
  • tests/test_run.py — test_llm_empty_model_not_injected is missing assert "ANTHROPIC_MODEL" not in env.

Important Files Changed

Filename Overview
src/vibepod/core/agents.py Extends the Claude agent's llm_env_map to forward the API key to ANTHROPIC_AUTH_TOKEN and the model to four variant-specific env vars; type annotation updated accordingly.
src/vibepod/commands/run.py Loop updated to handle `str
tests/test_agents.py Test updated to assert the new llm_env_map structure; correct and complete.
tests/test_run.py Integration tests updated to validate new env var injections; test_llm_empty_model_not_injected is missing an assertion for ANTHROPIC_MODEL not being injected when model is empty.
docs/llm.md Documentation updated to list all newly injected env vars and shows a complete example; accurate and clear.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LLM config enabled\nbase_url / api_key / model] --> B{Iterate llm_env_map}
    B --> C{env_var is str?}
    C -- yes --> D[targets = list of one string]
    C -- no --> E[targets = env_var list]
    D --> F
    E --> F[For each target:\nmerged_env.setdefault target value]
    F --> G{model set and\nllm_model_args present?}
    G -- yes --> H[Append --model model\nto command]
    G -- no --> I[No CLI flag added]

    subgraph Claude fan-out
        J[api_key] -->|maps to| K[ANTHROPIC_API_KEY\nANTHROPIC_AUTH_TOKEN]
        L[model] -->|maps to| M[ANTHROPIC_MODEL\nANTHROPIC_DEFAULT_OPUS_MODEL\nANTHROPIC_DEFAULT_SONNET_MODEL\nANTHROPIC_DEFAULT_HAIKU_MODEL]
        N[base_url] -->|maps to| O[ANTHROPIC_BASE_URL]
    end
Loading

Last reviewed commit: "Fixes forwarding of ..."

@nezhar nezhar force-pushed the extend-open-ll-auth branch from 6cb1a54 to ef059a9 Compare March 18, 2026 19:39
@nezhar nezhar force-pushed the extend-open-ll-auth branch from ef059a9 to 9653806 Compare March 18, 2026 19:40
@nezhar nezhar merged commit acd9344 into main Mar 18, 2026
19 checks passed
Comment thread tests/test_run.py
Comment on lines +977 to +979
assert "ANTHROPIC_DEFAULT_OPUS_MODEL" not in env
assert "ANTHROPIC_DEFAULT_SONNET_MODEL" not in env
assert "ANTHROPIC_DEFAULT_HAIKU_MODEL" not in env
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 Missing ANTHROPIC_MODEL assertion in empty-model test

test_llm_empty_model_not_injected now checks that the three ANTHROPIC_DEFAULT_*_MODEL vars are absent when model is empty, but it does not assert that ANTHROPIC_MODEL itself is also absent. Since "model" is now a key in llm_env_map (mapping to all four vars including ANTHROPIC_MODEL), the omission creates a coverage gap — a regression that accidentally injected ANTHROPIC_MODEL with a blank value wouldn't be caught.

Suggested change
assert "ANTHROPIC_DEFAULT_OPUS_MODEL" not in env
assert "ANTHROPIC_DEFAULT_SONNET_MODEL" not in env
assert "ANTHROPIC_DEFAULT_HAIKU_MODEL" not in env
assert "ANTHROPIC_MODEL" not in env
assert "ANTHROPIC_DEFAULT_OPUS_MODEL" not in env
assert "ANTHROPIC_DEFAULT_SONNET_MODEL" not in env
assert "ANTHROPIC_DEFAULT_HAIKU_MODEL" not in env

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