Skip to content

feat(claude): handle Vertex AI configuration in preWorkspaceStart - #2276

Merged
jeffmaury merged 1 commit into
openkaiden:mainfrom
jeffmaury:jeffmaury/GH-2247
Jun 26, 2026
Merged

jeffmaury merged 1 commit into
openkaiden:mainfrom
jeffmaury:jeffmaury/GH-2247

Conversation

@jeffmaury

Copy link
Copy Markdown
Contributor

Summary

Update Claude extension to handle Vertex AI-specific workspace configuration when a Vertex AI model is selected. This moves Vertex AI configuration logic from the core (agent-workspace-manager) into the Claude extension's preWorkspaceStart method.

Changes

  • Add Vertex AI detection in preWorkspaceStart method
  • Set CLAUDE_CODE_USE_VERTEX=1 when using Vertex AI models
  • Map GOOGLE_VERTEX_LOCATION to CLOUD_ML_REGION
  • Map GOOGLE_VERTEX_PROJECT to ANTHROPIC_VERTEX_PROJECT_ID
  • Add comprehensive tests for Vertex AI environment variable handling
  • Remove obsolete applyVertexAiConfiguration workaround from core
  • Remove obsolete tests for the old workaround

How It Works

  1. User selects a Vertex AI model with the Claude agent
  2. Core's ensureModelSecret processes the Vertex AI connection and adds GOOGLE_VERTEX_PROJECT and GOOGLE_VERTEX_LOCATION to the workspace environment
  3. Claude extension's preWorkspaceStart detects the Vertex AI model type, reads those Google env vars, and adds the Claude-specific env vars
  4. Workspace is created with all necessary environment variables for Claude Code to work with Vertex AI

Test Plan

  • All Claude extension tests pass (53 tests)
  • All agent-workspace-manager tests pass (121 tests)
  • Added 5 new tests for Vertex AI environment variable handling
  • Removed 3 obsolete tests for the old workaround

🤖 Generated with Claude Code

Fixes #2247

@jeffmaury
jeffmaury requested a review from a team as a code owner June 26, 2026 16:01
@jeffmaury
jeffmaury requested review from bmahabirbu and fbricon and removed request for a team June 26, 2026 16:01
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@jeffmaury, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 21 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ff03a302-499c-4398-bb59-a8a491a5d89c

📥 Commits

Reviewing files that changed from the base of the PR and between 2457d12 and b803307.

📒 Files selected for processing (2)
  • extensions/claude/src/claude-extension.spec.ts
  • extensions/claude/src/claude-extension.ts
📝 Walkthrough

Walkthrough

Adds Vertex AI environment injection to Claude workspace startup and removes Vertex AI-specific workspace configuration from agent secret setup. Related tests were updated to match the new behavior.

Changes

Vertex AI workspace updates

Layer / File(s) Summary
Claude preWorkspaceStart env injection
extensions/claude/src/claude-extension.ts, extensions/claude/src/claude-extension.spec.ts
preWorkspaceStart now reads Vertex project/location inputs from workspace environment variables and upserts the Claude Code Vertex AI variables for vertexai models; tests cover insertion, omission, and replacement cases.
Agent secret path cleanup
packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts, packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts
ensureModelSecret no longer applies Vertex AI-specific workspace configuration, and the tests now cover the incomplete-credentials skip path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • openkaiden/kaiden#2168: Adds the preWorkspaceStart hook in extensions/claude/src/claude-extension.ts, which this PR extends with Vertex AI environment injection.
  • openkaiden/kaiden#2243: Modifies the same Claude extension workspace-preparation path, including related preWorkspaceStart behavior.
  • openkaiden/kaiden#1877: Touches the same AgentWorkspaceManager.ensureModelSecret Vertex AI configuration path that this PR removes.

Suggested reviewers

  • benoitf
  • gastoner
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: handling Vertex AI configuration in preWorkspaceStart.
Description check ✅ Passed The description is directly related to the changeset and explains the Vertex AI configuration move.
Linked Issues check ✅ Passed The changes match #2247 by moving Vertex AI workspace handling from core into the Claude extension and adding coverage.
Out of Scope Changes check ✅ Passed No unrelated changes stand out; the removals and test updates support the Vertex AI configuration migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@extensions/claude/src/claude-extension.ts`:
- Around line 124-146: The Claude Vertex env var sync in claude-extension.ts
only adds/upserts values in the vertexai branch, but it never removes stale
CLAUDE_CODE_USE_VERTEX, CLOUD_ML_REGION, or ANTHROPIC_VERTEX_PROJECT_ID when
Vertex mode is no longer valid. Update the logic around the
context.model.llmMetadata?.name check so the workspace.environment is cleaned up
whenever the model is not vertexai or
GOOGLE_VERTEX_PROJECT/GOOGLE_VERTEX_LOCATION are missing, and keep the existing
upsert behavior when valid values are present.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: eed79867-4acc-4d14-8b1c-0259c9355cdf

📥 Commits

Reviewing files that changed from the base of the PR and between 8167345 and 2457d12.

📒 Files selected for processing (4)
  • extensions/claude/src/claude-extension.spec.ts
  • extensions/claude/src/claude-extension.ts
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts
💤 Files with no reviewable changes (2)
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: smoke-e2e-tests (dev) / ubuntu-24.04 (ollama)
  • GitHub Check: smoke-e2e-tests (prod) / ubuntu-24.04 (ollama)
  • GitHub Check: unit tests / windows-2022
  • GitHub Check: unit tests / macos-15
  • GitHub Check: Linux
  • GitHub Check: unit tests / ubuntu-24.04
  • GitHub Check: typecheck
  • GitHub Check: Windows
  • GitHub Check: linter, formatters
  • GitHub Check: macOS
⚠️ CI failures not shown inline (4)

GitHub Actions: fullsend / dispatch _ Route: feat(claude): handle Vertex AI configuration in preWorkspaceStart

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1mif [[ -f .fullsend/config.yaml ]]; then�[0m
 �[36;1m  KILL_SWITCH=$(yq '.kill_switch // false' .fullsend/config.yaml)�[0m
 �[36;1m  if [[ "$KILL_SWITCH" == "true" ]]; then�[0m
 �[36;1m    echo "::error::Kill switch is active — all agent dispatch halted"�[0m

GitHub Actions: fullsend / 6_dispatch _ Route.txt: feat(claude): handle Vertex AI configuration in preWorkspaceStart

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1m�[0m
 �[36;1mif [[ ! "$STAGE" =~ ^[a-z][a-z0-9_-]*$ ]]; then�[0m
 �[36;1m  echo "::error::Invalid stage name: must start with lowercase letter and contain only [a-z0-9_-]"�[0m

GitHub Actions: fullsend / dispatch _ Route: feat(claude): handle Vertex AI configuration in preWorkspaceStart

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1mEVENT_PAYLOAD=$(jq -c '{�[0m
 �[36;1m  issue: (.issue // null | if . then {number, html_url} else null end),�[0m
 �[36;1m  pull_request: (.pull_request // null | if . then {number, html_url,�[0m
 �[36;1m    head: {ref: .head.ref, sha: .head.sha, repo: {full_name: .head.repo.full_name}},�[0m
 �[36;1m    base: {ref: .base.ref, repo: {full_name: .base.repo.full_name}}} else null end),�[0m
 �[36;1m  comment: (.comment // null | if . then {body: .body[:4096]} else null end)�[0m
 �[36;1m}' "$GITHUB_EVENT_PATH") || {�[0m
 �[36;1m  echo "::error::Failed to extract event payload from GITHUB_EVENT_PATH"�[0m

GitHub Actions: fullsend / dispatch _ Route: feat(claude): handle Vertex AI configuration in preWorkspaceStart

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1m�[0m
 �[36;1mif [[ ! "$STAGE" =~ ^[a-z][a-z0-9_-]*$ ]]; then�[0m
 �[36;1m  echo "::error::Invalid stage name: must start with lowercase letter and contain only [a-z0-9_-]"�[0m
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use /@/ path aliases instead of relative paths for imports outside the current directory's module group; use relative imports only for sibling modules within the same directory

Files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts
extensions/*/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Register inference, container, and Kubernetes providers through the ProviderRegistry via extension APIs

Files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts
**/*.spec.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.spec.{ts,tsx,js,jsx}: Use test() instead of it() for test cases in Vitest unit tests
Use vi.mock(import('...')) for auto-mocking modules in unit tests; avoid manual mock factories when possible
Use vi.resetAllMocks() in beforeEach hooks instead of vi.clearAllMocks() for resetting mocks between tests
When an auto-mocked function or class method needs a real implementation, use vi.mocked(...) with the prototype pattern for class methods: vi.mocked(MyClass.prototype.myMethod).mockImplementation(...)

Files:

  • extensions/claude/src/claude-extension.spec.ts
🧠 Learnings (4)
📚 Learning: 2026-05-05T17:30:20.418Z
Learnt from: MarsKubeX
Repo: openkaiden/kaiden PR: 1671
File: extensions/vertex-ai/src/vertex-ai.ts:272-302
Timestamp: 2026-05-05T17:30:20.418Z
Learning: In the openkaiden/kaiden repo, for cloud inference provider extension code under `extensions/*/src/*.ts`, treat `ProviderConnectionStatus = 'unknown'` as a valid/expected value when registering provider connections (e.g., Gemini/Claude/Mistral/OpenAI-compatible/Vertex AI). `'unknown'` indicates the connection was set up but is not continuously monitored—so do not flag it as incorrect. Only Ollama is expected to use `'started'` because it actively polls a local server.

Applied to files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts
📚 Learning: 2026-05-05T17:44:50.991Z
Learnt from: MarsKubeX
Repo: openkaiden/kaiden PR: 1671
File: extensions/vertex-ai/src/vertex-ai.ts:363-387
Timestamp: 2026-05-05T17:44:50.991Z
Learning: In this repo (openkaiden/kaiden), do not raise a code review issue when an extension’s `InferenceProviderConnectionFactory.create` factory method implementation omits (or does not use) the optional `logger` and/or `CancellationToken` parameters in its method signature/implementation. Current extensions (e.g., Vertex AI, Gemini, Claude, Mistral, OpenAI-compatible) follow this pattern, so reviewers should treat it as acceptable for `extensions/*` TypeScript source files.

Applied to files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts
📚 Learning: 2026-05-12T10:01:14.248Z
Learnt from: MarsKubeX
Repo: openkaiden/kaiden PR: 1810
File: extensions/kdn/src/kdn-extension.ts:43-46
Timestamp: 2026-05-12T10:01:14.248Z
Learning: In this repo’s extension code, when logging from binary discovery/resolution logic (e.g., choosing/validating custom paths, extension storage locations, or bundled resource paths), it’s intentional to include full filesystem paths in `console.log`/`console.warn` (such as in `extensions/**/src/*-extension.ts`). During review, do not flag these specific full-path messages as a privacy/security issue as long as they are clearly part of the binary resolution steps. If full-path logging appears outside binary discovery/resolution, review/flag it as usual.

Applied to files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts
📚 Learning: 2026-05-12T17:14:02.153Z
Learnt from: MarsKubeX
Repo: openkaiden/kaiden PR: 1850
File: packages/renderer/src/lib/agent-workspaces/AgentWorkspaceList.svelte:66-70
Timestamp: 2026-05-12T17:14:02.153Z
Learning: When reviewing code that uses `AgentWorkspaceSummaryUI.runtime`, treat it as a required, non-null `string` per the `openkaiden/kdn-api` 0.12.0 schema. Therefore, code like `a.runtime.localeCompare(b.runtime)` is safe and should not trigger warnings about possible `undefined`/`null` values or suggestions to use nullish coalescing/optional chaining for `runtime` (unless the current local types still mark `runtime` as optional, indicating a schema/version mismatch).

Applied to files:

  • extensions/claude/src/claude-extension.ts
  • extensions/claude/src/claude-extension.spec.ts

Comment thread extensions/claude/src/claude-extension.ts
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@benoitf benoitf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Update Claude extension to handle Vertex AI-specific workspace configuration
when a Vertex AI model is selected. The extension now reads Google environment
variables (GOOGLE_VERTEX_PROJECT, GOOGLE_VERTEX_LOCATION) provided by the core
and adds Claude Code-specific environment variables needed for Vertex AI.

Changes:
- Add Vertex AI detection in preWorkspaceStart method
- Set CLAUDE_CODE_USE_VERTEX=1 when using Vertex AI models
- Map GOOGLE_VERTEX_LOCATION to CLOUD_ML_REGION
- Map GOOGLE_VERTEX_PROJECT to ANTHROPIC_VERTEX_PROJECT_ID
- Add comprehensive tests for Vertex AI environment variable handling

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Jeff MAURY <jmaury@redhat.com>

Fixes openkaiden#2247
@jeffmaury
jeffmaury force-pushed the jeffmaury/GH-2247 branch from 2457d12 to b803307 Compare June 26, 2026 19:31
@jeffmaury
jeffmaury enabled auto-merge (squash) June 26, 2026 19:32
@jeffmaury

Copy link
Copy Markdown
Contributor Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

@jeffmaury
jeffmaury merged commit f8fd597 into openkaiden:main Jun 26, 2026
31 checks passed
@jeffmaury
jeffmaury deleted the jeffmaury/GH-2247 branch June 26, 2026 19:51
bmahabirbu pushed a commit to bmahabirbu/kaiden that referenced this pull request Jun 29, 2026
…enkaiden#2276)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Jeff MAURY <jmaury@redhat.com>
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.

Update Vertex AI extension to provider workspace configuration changes

2 participants