PRD 0030: Deduplicate egress token resolution across backends #119
Reference in New Issue
Block a user
Delete Branch "prd-0030"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #118.
PRD:
8c2b59ca94/docs/prds/0030-deduplicate-egress-token-resolution.mdSummary
forward_host_credentials/CODEX_HOST_CREDENTIAL_TOKEN_REFresolution block from both backend launch files into a singleegress_resolve_token_values_with_providerinbot_bottle/egress.pyhost_env: objectannotation onsmolmachines._resolve_token_envtodict[str, str]Changes (3 commits)
6682357docs(prd): add PRD 003075f0f9drefactor(egress): deduplicate token resolution across backends8c2b59ccomplete(prd): mark PRD 0030 activeThe reason
CODEX_HOST_CREDENTIAL_TOKEN_REFexists as a sentinel is thategress_resolve_token_valuesassumes everytoken_refis an operator-set host env var it can look up inhost_env, and dies if it's missing. The Codex access token isn't in the operator's env; it's parsed out of~/.codex/auth.jsonat launch time. Without the sentinel,egress_resolve_token_valueswould hit the "env var unset" die for that slot.That said, the implicit suggestion is sound: instead of skipping the ref in
egress_resolve_token_valuesand post-processing inegress_resolve_token_values_with_provider, we could pre-populate a copy ofhost_envwith the Codex token value under the sentinel key before callingegress_resolve_token_values— then that function stays fully generic and the skip goes away. Thecodex_host_access_token()call would still live inegress_resolve_token_values_with_provider, so the external shape is the same. Want me to refactor along those lines?RE #119 (comment)
No, I'd like you to pass down a
provisioned_envinstead. Construct that map during provisioning steps, and merge it with the host env (have the provisioned env override the host env). That we we can keep codex specific provisioning things together.RE #119 (comment)
Good call — the sentinel skip was a code smell. Here is the revised plan:
provisioned_env: dict[str, str](default empty) toAgentProvisionPlan.agent_provision_plan, whenforward_host_credentials=Truefor Codex, callcodex_host_access_token(host_env)and store{CODEX_HOST_CREDENTIAL_TOKEN_REF: <value>}inprovisioned_env. This is already the prepare-time stage wherewrite_codex_dummy_auth_fileruns, so the access-token read is colocated with all other Codex-specific provisioning.egress_resolve_token_values_with_providerwith:egress_resolve_token_values(plan.egress_plan.token_env_map, {**dict(os.environ), **plan.agent_provision.provisioned_env}).egress_resolve_token_values_with_providerand remove theCODEX_HOST_CREDENTIAL_TOKEN_REFsentinel skip fromegress_resolve_token_values. The function becomes fully generic again.Implementing now.
didericis-claude referenced this pull request2026-06-02 01:01:21 -04:00