feat: Ambient Code Platform session backend#63
Conversation
f29ce33 to
f9ffa07
Compare
Implement the ambient backend, which manages agent sessions as remote Kubernetes pods through the Ambient Code Platform public API instead of local tmux sessions. Backend implementation (13 SessionBackend methods): - CreateSession via POST /v1/sessions with default task fallback - KillSession via DELETE (accepts full 2xx range + 404) - GetStatus maps ACP session + run status to SessionStatus - IsIdle/CaptureOutput/SendInput/Interrupt via corresponding endpoints - CheckApproval/Approve are no-ops (ambient has no terminal prompts) - DiscoverSessions matches by display_name on running/pending sessions - Available with 30s TTL cache, SkipTLSVerify for self-signed certs - waitForRunning polls until async session creation completes Integration changes: - Per-agent backend dispatch in liveness, broadcast, check-in, and session status (no longer assumes single default backend) - Skip model switching for non-tmux backends in runAgentCheckIn - AutoDiscoverAll runs discovery across all available backends - handleAgentSpawn/Restart/CreateAgents pass backend-specific opts, set BackendType on agent records, poll for ambient readiness - isNonSessionAgent recognizes "ambient" as session-based Frontend: - Replace disabled "cloud (soon)" button with active "ambient" selector - Conditionally show working directory field (tmux only) - Backend-specific help text in create agent dialog Deployment: - AMBIENT_API_URL, AMBIENT_SKIP_TLS_VERIFY in ConfigMap - AMBIENT_TOKEN via OpenShift Template (ambient-credentials.yaml) - Deployment references secret; Makefile includes in deploy target - Ambient auto-selected as default when tmux unavailable (distroless) Tests: 22 new tests covering all methods, status mapping, caching, discovery, transcript parsing, and polling via httptest mock server.
Create ambient-workflow/ with adapted boss commands (/boss.plan, /boss.check, /boss.ignite) for ACP sessions — no tmux dependencies, uses BOSS_URL and AGENT_NAME env vars. Wire workflow config into AmbientSessionBackend so all spawned sessions automatically get the workflow attached with activeWorkflow and environmentVariables in the ACP API request body.
…sions - Add Initial Prompt and Repos fields to the create agent dialog when ambient backend is selected (replacing Working Directory for tmux) - Pass repos and task through to AmbientCreateOpts in the backend handler - Cascade-delete the backing ACP session when an agent is deleted via the UI or API
The create agent and spawn handlers were lowercasing agent names before storing them in the agents map, causing a mismatch with the ambient backend which received the original cased name. Use resolveAgentName() instead, which does case-insensitive lookup but preserves original casing for new entries.
Hide the tmux-specific controls section (approval prompt, keystroke injection) for agents with backend_type === 'ambient'.
f9ffa07 to
f193bf3
Compare
Review — TASK-052 AmbientSessionBackend (#63)Overall: Solid implementation. The interface compliance is complete, error handling is consistent, and the 22 httptest-based tests give good coverage. PR is merged and all tests pass clean with -race. StrengthsInterface implementation is complete and correct Compile-time checks at the top (
Single place for auth headers, Content-Type, and request construction. All methods delegate through it correctly.
Treating 404 as success is correct — the session is gone either way, which is the goal.
Falling back to
Using
30s TTL with mutex protects the cache correctly. Checking Observations (no change needed)
Tests — 22 httptest mock server tests cover all methods including status mapping, TTL caching, discovery, and polling. Testing through the HTTP layer is the right approach. Verdict: Approved. No required changes. |
Summary
AmbientSessionBackendimplementing theSessionBackendinterface for remote agent sessions via the ACP public APIambient-workflow/with adapted/boss.plan,/boss.check,/boss.ignitecommands for ACP sessions (no tmux dependencies, usesBOSS_URLandAGENT_NAMEenv vars)activeWorkflowandenvironmentVariablesset on the K8s CRBackend changes
session_backend.goAmbientCreateOptswithWorkflowRef,Repos,EnvVarsfieldssession_backend_ambient.goSessionBackendimplementation against ACP public API;CreateSessionincludesactiveWorkflow,environmentVariables, andreposin the request bodyserver.goAMBIENT_WORKFLOW_*andCOORDINATOR_EXTERNAL_URLenv varshandlers_agent.gorepos/taskto create request; cascade-delete sessions on agent removal; preserve name casinglifecycle.goresolveAgentNameinstead ofToLowerfor agent map keysdeploy/openshift/configmap.yamlWorkflow files (
ambient-workflow/).ambient/ambient.json.claude/commands/boss.ignite.md$BOSS_URL,$AGENT_NAMEenv vars, no tmux.claude/commands/boss.check.md$BOSS_URLenv var,$AGENT_NAMEfallback.claude/commands/boss.plan.mdCLAUDE.mdFrontend changes
Test plan
go test -race ./internal/coordinator/passesnpm run buildsucceedsactiveWorkflow,environmentVariables, andreposappear on the K8s AgenticSession CRNOTE
This relies on the changes in ambient-code/platform#855