Minimal Amazon Bedrock AgentCore Runtime container that exposes:
GET /pingPOST /invocations
The AgentCore adapter starts opencode serve inside the container and maps each
AgentCore runtime session to an OpenCode session. POST /invocations calls the
OpenCode server's session message API and streams the returned OpenCode parts
over SSE.
There is no direct Bedrock fallback route. If OpenCode fails, the stream returns
an opencode_error so the control plane cannot mistake fallback output for an
OpenCode response. The default model is Claude Sonnet 4.5 through the Bedrock
inference profile because that path is accepted by OpenCode's Bedrock provider.
docker build --platform linux/arm64 -t opencode-agentcore-poc:latest .docker run --rm -p 8080:8080 \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-e AWS_REGION=us-west-2 \
-e AWS_DEFAULT_REGION=us-west-2 \
opencode-agentcore-poc:latestcurl -N http://localhost:8080/invocations \
-H 'content-type: application/json' \
-d '{"prompt":"who are you?","systemPrompt":"You are OpenCode. When asked who you are, say exactly: I am OpenCode."}'aws bedrock-agentcore invoke-agent-runtime \
--region us-west-2 \
--agent-runtime-arn "$AGENT_RUNTIME_ARN" \
--runtime-session-id "opencode-poc-session-000000000000000001" \
--content-type application/json \
--accept text/event-stream \
--cli-binary-format raw-in-base64-out \
--payload '{"prompt":"who are you?","systemPrompt":"You are OpenCode. When asked who you are, say exactly: I am OpenCode."}' \
/tmp/opencode-agentcore.outOr use the smoke script, which exits non-zero if the runtime fails before OpenCode emits text:
AGENT_RUNTIME_ARN="$AGENT_RUNTIME_ARN" python3 scripts/invoke_poc.pyOPENCODE_MODEL, defaults toamazon-bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0BEDROCK_MODEL_ID, defaults tous.anthropic.claude-sonnet-4-5-20250929-v1:0AWS_REGION, defaults tous-west-2