diff --git a/profiles/agent-opencode.yaml b/profiles/agent-opencode.yaml index 797121f..ffd96d4 100644 --- a/profiles/agent-opencode.yaml +++ b/profiles/agent-opencode.yaml @@ -1,8 +1,12 @@ # OpenCode agent configuration. # +# OpenCode uses ANTHROPIC_BASE_URL with inference.local/v1 (note the /v1 suffix). +# Without /v1, OpenCode sends POST /messages instead of POST /v1/messages, +# which doesn't match the inference route pattern. +# See: https://github.com/NVIDIA/OpenShell/blob/main/docs/providers/google-vertex-ai.mdx +# # Usage: -# harness up -f agents/opencode.yaml -# harness up --agent opencode +# harness apply --agent opencode name: opencode-agent entrypoint: opencode @@ -17,6 +21,7 @@ providers: JIRA_USERNAME: ${JIRA_USERNAME} - profile: gws +# OpenCode needs /v1 suffix on ANTHROPIC_BASE_URL (different from Claude Code). env: - OPENAI_BASE_URL: https://inference.local/v1 - OPENAI_API_KEY: sk-ant-openshell-proxy-managed + ANTHROPIC_BASE_URL: https://inference.local/v1 + ANTHROPIC_API_KEY: sk-ant-openshell-proxy-managed diff --git a/profiles/images/sandbox-default/opencode.json b/profiles/images/sandbox-default/opencode.json index 8a8d30e..7e32ede 100644 --- a/profiles/images/sandbox-default/opencode.json +++ b/profiles/images/sandbox-default/opencode.json @@ -1,11 +1,11 @@ { + "$schema": "https://opencode.ai/config.json", "mcp": { "atlassian": { "type": "local", - "command": "/sandbox/.venv/bin/mcp-atlassian", - "args": [], + "command": ["/sandbox/.venv/bin/mcp-atlassian"], "enabled": true, - "env": { + "environment": { "READ_ONLY_MODE": "true" } } diff --git a/test/configs/agent-opencode-vertex.yaml b/test/configs/agent-opencode-vertex.yaml index de88f6d..06c9908 100644 --- a/test/configs/agent-opencode-vertex.yaml +++ b/test/configs/agent-opencode-vertex.yaml @@ -1,11 +1,10 @@ -# OpenCode with Vertex AI via inference.local proxy. -# OpenCode uses OpenAI-compatible API at inference.local/v1. -# The proxy translates to Vertex AI Anthropic models. +# OpenCode with Vertex AI via inference.local/v1. +# OpenCode uses ANTHROPIC_BASE_URL (not OPENAI_BASE_URL) with /v1 suffix. # Requires: gcloud auth application-default login, ANTHROPIC_VERTEX_PROJECT_ID. name: test-opencode entrypoint: opencode providers: - profile: vertex-local env: - OPENAI_BASE_URL: https://inference.local/v1 - OPENAI_API_KEY: sk-ant-openshell-proxy-managed + ANTHROPIC_BASE_URL: https://inference.local/v1 + ANTHROPIC_API_KEY: sk-ant-openshell-proxy-managed diff --git a/test/suite/run.sh b/test/suite/run.sh index 2c5cbfa..655f291 100755 --- a/test/suite/run.sh +++ b/test/suite/run.sh @@ -305,7 +305,7 @@ if $LIVE && "$CLI" inference get >/dev/null 2>&1; then "$CLI" sandbox exec --name test-agent-int -- \ bash -c 'result=$(echo "respond with ok" | claude --print 2>&1); test -n "$result"' - # OpenCode uses inference.local/v1 (OpenAI-compatible) via the proxy. + # OpenCode uses ANTHROPIC_BASE_URL=inference.local/v1 (note /v1 suffix) SANDBOXES_TO_CLEAN+=(test-opencode-int) run_test "agent: opencode inference via vertex" \ bash -c '"$1" apply -f "$2" --name test-opencode-int >/dev/null 2>&1 && \ @@ -340,16 +340,15 @@ if $LIVE && "$CLI" inference get >/dev/null 2>&1; then fi else skip_test "agent: claude inference via vertex" "sandbox not ready" - skip_test "agent: opencode inference via vertex" "sandbox not ready" skip_test "agent: github via gh cli" "sandbox not ready" skip_test "agent: claude uses jira mcp" "sandbox not ready" skip_test "agent: gws gmail via proxy token" "sandbox not ready" - skip_test "agent: opencode built-in profile" "sandbox not ready" fi # Test the built-in opencode profile (--agent opencode) with all providers. # Verifies the shipped profile works end-to-end with Vertex via inference.local/v1. SANDBOXES_TO_CLEAN+=(test-oc-builtin) + SANDBOXES_TO_CLEAN+=(test-oc-builtin) run_test "agent: opencode built-in profile" \ bash -c '"$1" apply --agent opencode --name test-oc-builtin >/dev/null 2>&1 && \ for i in $(seq 1 10); do "$1" describe test-oc-builtin >/dev/null 2>&1 && break; sleep 0.5; done && \ @@ -360,11 +359,9 @@ if $LIVE && "$CLI" inference get >/dev/null 2>&1; then "$HARNESS" delete --sandboxes --providers >/dev/null 2>&1 || true else skip_test "agent: claude inference via vertex" "ANTHROPIC_VERTEX_PROJECT_ID not set" - skip_test "agent: opencode inference via vertex" "ANTHROPIC_VERTEX_PROJECT_ID not set" skip_test "agent: github via gh cli" "ANTHROPIC_VERTEX_PROJECT_ID not set" skip_test "agent: claude uses jira mcp" "ANTHROPIC_VERTEX_PROJECT_ID not set" skip_test "agent: gws gmail via proxy token" "ANTHROPIC_VERTEX_PROJECT_ID not set" - skip_test "agent: opencode built-in profile" "ANTHROPIC_VERTEX_PROJECT_ID not set" fi echo ""