opencode: support vertex-ai auth#214
Conversation
There was a problem hiding this comment.
Code Review
This pull request enables Vertex AI authentication for the OpenCode harness by updating its capabilities and implementing auth resolution logic. Key changes include refactoring command argument construction, adding a resolveVertexAI helper function, and updating the ResolveAuth method to support both explicit and auto-detected Vertex AI configurations. Feedback was provided to improve the clarity and consistency of the error message when no valid authentication method is found by explicitly listing the required environment variables.
9609b7d to
d0dfe9e
Compare
PR Review: opencode: support vertex-ai authPR: #214 Executive SummaryMedium risk — request changes. Enables Vertex AI as an auth method for the OpenCode harness by flipping the capability flag, adding a Files Changed (1 file, +34 / -9)
Critical / Blocking Issues1. Auto-detect priority puts Vertex AI ahead of API keys — silent behavior regressionFile: // Auto-detect preference order: VertexAi → AnthropicAPIKey → OpenAIAPIKey → OpenCodeAuthFile → error
if auth.GoogleCloudProject != "" && auth.GoogleCloudRegion != "" {
return o.resolveVertexAI(auth), nil
}
if auth.AnthropicAPIKey != "" { ... }Compare with the Claude Code harness, which intentionally puts Vertex last in the auto-detect chain:
Many GCP users have Suggested fix: Move the Vertex AI block to after the auth-file block, matching the Claude Code precedence. Update the comment accordingly. 2. Auto-detect doesn't gate on actual credentials being presentFile: if auth.GoogleCloudProject != "" && auth.GoogleCloudRegion != "" {
return o.resolveVertexAI(auth), nil
}
Compare with hasVertexCreds := auth.GoogleAppCredentials != "" || auth.GCPMetadataMode == "assign"
if hasVertexCreds && auth.GoogleCloudProject != "" && auth.GoogleCloudRegion != "" {
return c.resolveVertexAI(auth), nil
}Suggested fix: Add the same 3. Env vars likely won't activate Vertex in opencodeFile: EnvVars: map[string]string{
"VERTEX_LOCATION": auth.GoogleCloudRegion,
"GOOGLE_CLOUD_REGION": auth.GoogleCloudRegion,
"GOOGLE_CLOUD_PROJECT": auth.GoogleCloudProject,
},Two concerns: (a) opencode is built on the Vercel AI SDK. Its {
"$schema": "https://opencode.ai/config.json",
"theme": "matrix"
}No provider block, no model selection. Without (b) Suggested fix: Smoke-test end-to-end with a real opencode + Vertex run. Verify which env vars opencode actually reads and/or add a provider block to the embedded Observations4. No test coverage for the new path
Tests to add:
5. Bundled, unrelated
|
opencodefor vertex-ai auth, tested "in production"--promptflag when no task consuming next arg from baseArgs as prompt, i.e. if no task, should not even supply the flag