You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 27, 2026. It is now read-only.
Some ACP providers authenticate from a file on disk, not an env var: Codex reads $CODEX_HOME/auth.json, Gemini (Vertex AI) reads a service-account JSON. The user supplies the credential as a pasted blob (a reserved "file-content" secret); the SDK must materialise it to the file path the CLI expects, with the right env var pointing at it.
Mechanism — declarative, registry-driven
Add an ACPFileSecretSpec (frozen, serialisable) plus a per-provider file_secrets list on the ACP_PROVIDERS registry, mapping a reserved secret name → target filename + the env var that points at it. Materialisation is generic and command-independent (keyed off the configured secret_name, so custom/aliased acp_commands still work):
Materialise into the persisted, per-conversation root (#1019 / [ACP on Cloud] Persistence: durable config + native session storage across pod recycles #2116), e.g. <conversations>/{id.hex}/acp/{provider}/ — seed-if-absent, no TemporaryDirectory, no delete-on-cleanup; write 0600 files in 0700 dirs. So a token the CLI refreshes on disk survives a recycle, and a stale paste never overwrites it.
Point the provider's data-dir env (CODEX_HOME / GOOGLE_APPLICATION_CREDENTIALS) at the materialised path.
Make Codex auth detectionCODEX_HOME-aware — today it hardcodes ~/.codex/auth.json (acp_agent.py:234), so a relocated CODEX_HOME is never detected.
Tests: Codex auth.json + Gemini Vertex SA materialise to the right path; the env vars point at them; detection selects the subscription/Vertex auth method; the file survives across runs (seed-if-absent, not clobbered).
Depends on
#2113 (provides the secret_registry source + the per-provider data-dir env via create_agent). Materialisation target defined in #2114 / #2116.
changed the title [-]ACP file-secret materialisation: pick ONE mechanism (#3269 vs #3292) + read from state.secret_registry[/-][+][ACP on Cloud] SDK: pick ONE file-secret materialisation mechanism (+ read from secret_registry)[/+]on Jun 2, 2026
changed the title [-][ACP on Cloud] SDK: pick ONE file-secret materialisation mechanism (+ read from secret_registry)[/-][+][ACP on Cloud] SDK: materialise reserved file-content auth secrets (Codex auth.json, Gemini Vertex SA)[/+]on Jun 2, 2026
Should file-materialisation live in the SDK (this PR) or in the downstream app?
Re-raising the May-15 thread question (@xingyao's advice: let the downstream app own the credential files, keep the SDK out of it). Now that the cloud architecture is formalised, here's where I land.
The thread conflated two deployment targets
Local unsandboxed (the desktop/npm run dev case, canvas#348): the local CLI is already logged in (~/.codex/auth.json, ~/.gemini/…). Xingyao is right here — the SDK shouldn't materialise anything.
In cloud, "downstream writes the file" is physically impossible without building a separate credential-file-upload channel parallel to the secret channel. Whatever materialises the credential must run in-pod, at subprocess-spawn time. And the wiring is irreducibly SDK-side regardless of where the bytes are written:
setting CODEX_HOME / GOOGLE_APPLICATION_CREDENTIALS on the subprocess,
knowing the durable per-conversation root (state.persistence_dir),
CODEX_HOME-aware detection in _select_auth_method,
seed-if-absent so a token Codex rewrites on refresh survives a pod recycle and a stale paste can't clobber the live one.
Splitting the file-write (downstream) from this wiring (SDK) would fracture one tightly-coupled concern across two repos.
"Two auth paths" is intrinsic, not introduced by this PR
Codex/Gemini subscription auth is file-based — there is no env var that authenticates a Codex subscription. The file path has to exist somewhere no matter what; the only choice is where it lives, not whether. Moving it downstream doesn't remove the second path, it relocates it to a place that can't reach the pod — and bypasses the secret channel's masking/redaction (#1023).
This PR is already the hybrid the advice was asking for
The design separates mechanism (write file, set env, seed-if-absent, 0600/0700, detection — SDK-owned, in-pod, cloud-capable) from policy (which secret → which file/env/dir for which CLI — expressed as data via ACPFileSecretSpec + an overridable acp_file_secrets field). So a downstream app can support a new file-auth CLI by supplying a spec, with no SDK change — exactly the "the app decides which CLIs it supports" flexibility from the thread.
And it's a no-op in the local case: _materialise_file_secrets only acts when a reserved secret is actually present; otherwise detection falls back to the local login files unchanged. So Xingyao's "bare unsandboxed agent-server in a VM" case keeps working untouched (the only detection change — CODEX_HOME-awareness — is strictly additive).
Recommendation
Keep the mechanism in the SDK; keep policy as overridable data (i.e. what this PR ships). Reverting to "canvas owns the files" optimises the local case (already a no-op here) at the cost of the cloud case — the actual goal of OpenHands/OpenHands#15746 — and re-creates an ACP-special-case parallel channel, the opposite of the epic's guiding principle ("collapse onto state.secret_registry").
One genuinely open sub-decision worth a call: openhands-sdk core vs openhands-agent-server as the home. Both run in-pod and both solve cloud. It's in core today because ACPAgent itself lives there and policy-as-data keeps core from hardcoding CLI quirks — but if we'd rather core stay strictly CLI-agnostic, the agent-server layer is a defensible alternative. Not canvas, though — that can't reach the pod FS.
@xingyaoww — does the policy/mechanism split address the original concern, or do you want this in openhands-agent-server rather than sdk-core?
I think we should follow the architectural advice in spirit, but not pivot to moving file materialisation out of the SDK entirely.
The right split seems to be:
SDK owns mechanism: write the credential file inside the runtime pod before spawning the ACP subprocess, set the path env var, enforce 0600/0700, preserve refreshed files seed-if-absent, and honor final env precedence. This needs to happen where the CLI actually runs and where state.secret_registry, agent_context.secrets, persistence_dir, and acp_env precedence are all visible.
Downstream/product owns policy: which reserved secret maps to which filename/env/subdir for a provider. The PR head already mostly supports this via public ACPFileSecretSpec plus ACPAgent.acp_file_secrets / settings pass-through, with built-in defaults and downstream override/opt-out.
Pros of this direction:
Avoids hard-coding product/provider policy too deeply in SDK internals.
Lets Canvas/OpenHands or another downstream support custom ACP servers without an SDK release.
Keeps the security-sensitive and pod-local operation in the only layer that can reliably do it.
Preserves direct SDK ergonomics through built-in Codex/Gemini defaults.
Matches the broader epic direction: collapse ACP credentials onto the normal secret/state path, but keep ACP subprocess setup as an SDK responsibility.
Risks/tradeoffs:
If downstream must explicitly pass specs, missing wiring can regress auth, so product-level tests are needed.
The SDK still has some provider-specific auth-method detection (chatgpt, vertex-ai, API-key fallback), so the abstraction is not perfectly policy-free.
Removing built-in defaults entirely would make direct SDK usage worse and increase rollout risk for a P0 cloud path.
Keep built-in Codex/Gemini defaults, but frame them as convenience defaults, not the only policy source.
Have OpenHands/Canvas cloud construction pass explicit acp_file_secrets for the selected provider once that wiring is ready, so product policy is deliberate.
Add/track product-level coverage that Canvas passes the expected Codex/Gemini specs.
Update the PR body to remove stale references to the old ACP_FILE_SECRETS_BY_NAME registry and describe the current acp_file_secrets mechanism/policy split.
Net: I would not do a broad rewrite. The PR already made the important strategic correction. Merge direction should be “SDK mechanism + downstream-overridable policy,” not “all provider file-auth logic lives outside the SDK.”
Done — implemented in software-agent-sdk#3474 (merged 557f4664). Ships the mechanism/policy split: ACPFileSecretSpec + overridable acp_file_secrets (with built-in Codex/Gemini convenience defaults), materialises reserved file-content secrets seed-if-absent into <persistence_dir>/acp/{provider}/ (0600/0700), reads state.secret_registry then the agent_context.secrets drain, sets CODEX_HOME/GOOGLE_APPLICATION_CREDENTIALS, and adds CODEX_HOME-aware + vertex-ai detection. Validated e2e in a Docker container for all three providers (Codex via materialised auth.json→chatgpt, Claude via env token, Gemini via materialised SA→vertex-ai), which also confirmed the vertex-ai method id and yolo mode are real on the pinned CLIs. Follow-ups (downstream wiring: Canvas/OpenHands pass explicit specs + product tests) tracked toward #2117/#1016/#1013.
Activity
[-]ACP file-secret materialisation: pick ONE mechanism (#3269 vs #3292) + read from state.secret_registry[/-][+][ACP on Cloud] SDK: pick ONE file-secret materialisation mechanism (+ read from secret_registry)[/+][-][ACP on Cloud] SDK: pick ONE file-secret materialisation mechanism (+ read from secret_registry)[/-][+][ACP on Cloud] SDK: materialise reserved file-content auth secrets (Codex auth.json, Gemini Vertex SA)[/+]simonrosenberg commentedon Jun 3, 2026
Should file-materialisation live in the SDK (this PR) or in the downstream app?
Re-raising the May-15 thread question (@xingyao's advice: let the downstream app own the credential files, keep the SDK out of it). Now that the cloud architecture is formalised, here's where I land.
The thread conflated two deployment targets
npm run devcase, canvas#348): the local CLI is already logged in (~/.codex/auth.json,~/.gemini/…). Xingyao is right here — the SDK shouldn't materialise anything.HOMEis ephemeral, and the downstream app (canvas browser / OpenHands backend pod) has no filesystem access to the runtime pod. The only channel into the pod is the conversation transport →state.secret_registry.The decisive constraint
In cloud, "downstream writes the file" is physically impossible without building a separate credential-file-upload channel parallel to the secret channel. Whatever materialises the credential must run in-pod, at subprocess-spawn time. And the wiring is irreducibly SDK-side regardless of where the bytes are written:
CODEX_HOME/GOOGLE_APPLICATION_CREDENTIALSon the subprocess,state.persistence_dir),CODEX_HOME-aware detection in_select_auth_method,Splitting the file-write (downstream) from this wiring (SDK) would fracture one tightly-coupled concern across two repos.
"Two auth paths" is intrinsic, not introduced by this PR
Codex/Gemini subscription auth is file-based — there is no env var that authenticates a Codex subscription. The file path has to exist somewhere no matter what; the only choice is where it lives, not whether. Moving it downstream doesn't remove the second path, it relocates it to a place that can't reach the pod — and bypasses the secret channel's masking/redaction (#1023).
This PR is already the hybrid the advice was asking for
The design separates mechanism (write file, set env, seed-if-absent,
0600/0700, detection — SDK-owned, in-pod, cloud-capable) from policy (which secret → which file/env/dir for which CLI — expressed as data viaACPFileSecretSpec+ an overridableacp_file_secretsfield). So a downstream app can support a new file-auth CLI by supplying a spec, with no SDK change — exactly the "the app decides which CLIs it supports" flexibility from the thread.And it's a no-op in the local case:
_materialise_file_secretsonly acts when a reserved secret is actually present; otherwise detection falls back to the local login files unchanged. So Xingyao's "bare unsandboxed agent-server in a VM" case keeps working untouched (the only detection change —CODEX_HOME-awareness — is strictly additive).Recommendation
Keep the mechanism in the SDK; keep policy as overridable data (i.e. what this PR ships). Reverting to "canvas owns the files" optimises the local case (already a no-op here) at the cost of the cloud case — the actual goal of OpenHands/OpenHands#15746 — and re-creates an ACP-special-case parallel channel, the opposite of the epic's guiding principle ("collapse onto
state.secret_registry").One genuinely open sub-decision worth a call:
openhands-sdkcore vsopenhands-agent-serveras the home. Both run in-pod and both solve cloud. It's in core today becauseACPAgentitself lives there and policy-as-data keeps core from hardcoding CLI quirks — but if we'd rather core stay strictly CLI-agnostic, the agent-server layer is a defensible alternative. Not canvas, though — that can't reach the pod FS.@xingyaoww — does the policy/mechanism split address the original concern, or do you want this in
openhands-agent-serverrather than sdk-core?simonrosenberg commentedon Jun 3, 2026
Strategy read after reviewing OpenHands/software-agent-sdk#3474, this issue, and the surrounding epic/issues:
I think we should follow the architectural advice in spirit, but not pivot to moving file materialisation out of the SDK entirely.
The right split seems to be:
0600/0700, preserve refreshed files seed-if-absent, and honor final env precedence. This needs to happen where the CLI actually runs and wherestate.secret_registry,agent_context.secrets,persistence_dir, andacp_envprecedence are all visible.ACPFileSecretSpecplusACPAgent.acp_file_secrets/ settings pass-through, with built-in defaults and downstream override/opt-out.Pros of this direction:
Risks/tradeoffs:
chatgpt,vertex-ai, API-key fallback), so the abstraction is not perfectly policy-free.Recommended tactical path for OpenHands/OpenHands#3474:
acp_file_secretsfor the selected provider once that wiring is ready, so product policy is deliberate.ACP_FILE_SECRETS_BY_NAMEregistry and describe the currentacp_file_secretsmechanism/policy split.Net: I would not do a broad rewrite. The PR already made the important strategic correction. Merge direction should be “SDK mechanism + downstream-overridable policy,” not “all provider file-auth logic lives outside the SDK.”
simonrosenberg commentedon Jun 3, 2026
Done — implemented in software-agent-sdk#3474 (merged
557f4664). Ships the mechanism/policy split:ACPFileSecretSpec+ overridableacp_file_secrets(with built-in Codex/Gemini convenience defaults), materialises reserved file-content secrets seed-if-absent into<persistence_dir>/acp/{provider}/(0600/0700), readsstate.secret_registrythen theagent_context.secretsdrain, setsCODEX_HOME/GOOGLE_APPLICATION_CREDENTIALS, and addsCODEX_HOME-aware +vertex-aidetection. Validated e2e in a Docker container for all three providers (Codex via materialised auth.json→chatgpt, Claude via env token, Gemini via materialised SA→vertex-ai), which also confirmed thevertex-aimethod id andyolomode are real on the pinned CLIs. Follow-ups (downstream wiring: Canvas/OpenHands pass explicit specs + product tests) tracked toward #2117/#1016/#1013.