A box never falls back to the organization's model keys

Merged
SA
2mo ago
+19-15

Removes the ?? env.ANTHROPIC_API_KEY and ?? env.OPENAI_API_KEY fallbacks in deriveSandboxCredentials. A box's model credential now comes only from the creator's sign-in (Settings › Agents) or the environment's variables, so nothing lands on the org keys anymore. The Vercel variables stay: the Slack agent and cloud workspace naming still read them.

Known gap, recorded in docs/cloud-sandbox-considerations.md: nothing at workspace creation checks that the chosen agent has a sign-in. A person without one gets a box whose agent sits on a login prompt, and an automation-created box does the same silently. The release probe only checks the Anthropic swap when the probe environment carries a key, so it skips rather than fails.

Credentials tests pass (8); trpc typecheck clean.

https://claude.ai/code/session_01RL946q6aRucLVJs659sW24


Summary by cubic

Removes the fallback to the organization's Anthropic and OpenAI keys when deriving a sandbox's model credentials, so agent usage no longer lands on the org's bill without attribution or cap.

Known gap

  • Nothing at workspace creation checks that the chosen agent has a sign-in, so a person without one gets a box whose agent sits on a login prompt; an automation-created box does the same silently.

Summary by CodeRabbit

  • Credential Handling
    • Sandboxes now use credentials from the person’s provider sign-in or workspace environment variables. Organization-level keys are no longer used as a fallback.
    • Provider sign-in credentials take precedence over environment variables.
  • Workspace Setup
    • Creating a workspace does not verify that the selected agent is signed in. If it isn’t, the agent remains at its login prompt, including in workspaces created through automation.
    • Credential changes reach running sandboxes within one keepalive.