Repository navigation
MARSOHS-2740: use DigitalOcean Inference for --model on claude-code and codex - #2118
SSharma-10 merged 4 commits into
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
…nd codex For --harness claude-code and --harness codex, a non-empty --model now means DigitalOcean Inference when no Anthropic or OpenAI key is passed with --secret. The generated manifest then leaves out the vendor key slot, so the existing key-issuing request supplies the key instead of failing on a missing local ANTHROPIC_API_KEY or OPENAI_API_KEY. Passing either vendor key with --secret keeps the harness's own slot as before, and a key exported in the shell is ignored with one stderr note. The claude-code validation warning about HARNESS_INFERENCE_MODEL no longer fires when a DigitalOcean key will be used, and still fires when a native key, or only an OpenAI key, is present. Help text and --dry-run explain how the key is chosen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
03199b1 to
db75457
Compare
|
Live check against the API. |
|
Review notes.
|
…ey placeholders by slot (MARSOHS-2740)
With --harness claude-code or codex, --model now runs on DigitalOcean
Inference even when ANTHROPIC_API_KEY or OPENAI_API_KEY is exported.
The stderr note, the --dry-run note, the --model flag help and the
create help now say that model usage is billed to the DigitalOcean team
and how to stay on your own vendor account.
hasKeyPlaceholder now reads the env and secret slots of the inference
and vendor keys instead of searching the whole manifest, so a ${VAR}
inside a prompt no longer suppresses the --dry-run note.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks @sanpj2292. Addressed in cec5953.
|
sanpj2292
left a comment
There was a problem hiding this comment.
LGTM. The billing change is now flagged in the description and in the CLI ("billed to your DigitalOcean team" in the stderr note, --dry-run output and help), and hasKeyPlaceholder now checks only the key slots in env and secrets.
This approval covers the code. The behaviour change (an exported vendor key no longer keeps a --model session on the vendor's billing) still needs the owner's approval, as the description says.
Merge note: this PR conflicts with #2093 in commands/agents.go.
Conflict in commands/agents_test.go: both sides appended tests at the end of the file (this branch's JSON permission-line test, main's `logs` tests). Kept both. digitalocean#2118's --model create tests had no ValidatePolicy stub. Every --harness create now runs the policy check alongside create, so the unexpected call failed inside that goroutine and create waited on it forever (the package timed out). They now allow the check without asserting its line, since create is made to fail and the check may be cancelled. Co-authored-by: Cursor <cursoragent@cursor.com>

Summary
doctl harness-runtime create --harness claude-code --model kimi-k3failed before creating anything:--harness codex --model kimi-k3failed the same way onOPENAI_API_KEY. Creating the same harness and model in the console works, using a DigitalOcean Inference key and no vendor key.The cause was ordering.
--harness claude-code/codexalways wrote a${ANTHROPIC_API_KEY}/${OPENAI_API_KEY}placeholder into the manifest, and doctl resolves placeholders locally before any API call. So the managed-key request added in #2114 was never reached.Behaviour change: billing (needs owner approval)
For
--harness claude-codeand--harness codex, a user who hasANTHROPIC_API_KEYorOPENAI_API_KEYexported and passes--modelused to run on their own vendor key, billed by the vendor. After this change that session runs on DigitalOcean Inference, billed to the user's DigitalOcean team. Only an explicit--secret ANTHROPIC_API_KEY=…/--secret OPENAI_API_KEY=…keeps them on their own vendor account. Like #2111 and #2112, this needs the owner's sign-off before merge.How users learn about it:
Using DigitalOcean Inference for kimi-k3; model usage is billed to your DigitalOcean team. ANTHROPIC_API_KEY in your environment is not used; to use and be billed on your own Anthropic account, pass --secret ANTHROPIC_API_KEY=... (or =@file).--dry-runstderr:A DigitalOcean Inference key will be requested for this session when it is created; model usage is billed to your DigitalOcean team.--modelflag help and the create/launch help both say the session is billed to the team, and that an exported key no longer counts.What changes
For
--harness claude-codeand--harness codex, a non-empty--modelnow means DigitalOcean Inference:--model kimi-k3--model kimi-k3withANTHROPIC_API_KEYexported in the shell--model X --secret ANTHROPIC_API_KEY=…(orOPENAI_API_KEYfor codex)--model X --secret HARNESS_INFERENCE_API_KEY=…--model Xwith the other vendor's key in--secret--modelWhy an exported key does not count: inside the session a vendor key takes precedence over the DigitalOcean key. If doctl forwarded it,
kimi-k3would be sent to the vendor and fail at the first prompt instead of at create. An explicit--secretis a clear request; an exported variable usually belongs to another tool.Also:
--dry-runsays on stderr when a DigitalOcean Inference key will be requested and that it bills the team. It stays quiet when an inference or vendor key'senv/secretsslot holds an unresolved${VAR}, because create would ask for that key instead. A${VAR}elsewhere (for example in a prompt) does not count.--modeland the create/launch help explain the choice.Unchanged:
codex-agentapi(OpenAI runs that agent loop, so it needs an OpenAI key), opencode, openhands, hermes,--specmanifests and--from-config.Testing
Live, against the API, on 2026-11-11 (each session and its Agent Config was removed afterwards):
create --harness codex --model kimi-k3, no vendor keycreate --harness claude-code --model kimi-k3, no vendor keyANTHROPIC_API_KEYexported--harness claude-code --model kimi-k3 --secret OPENAI_API_KEY=…ANTHROPIC_API_KEY, and no session is createdUnit tests in
commands/agents_model_inference_test.gocover every row of the table above, the validation warning both ways,--dry-run,-o jsonstdout staying clean, and the shared create/launch path. I also confirmed that each of these tests fails when its rule is broken: counting only one vendor's key, dropping the OpenAI-only warning, and restoring the old warning condition.go test ./commands/ ./do/passes exceptTestRegistryLogout, which also fails on unmodifiedmainin my environment (it needs the OS keychain).Notes for review
needsManagedModelAccessKeyis unchanged; this change only stops writing the vendor slot that kept it from running.Refs: MARSOHS-2740
🤖 Generated with Claude Code