Skip to content

refactor(cliproxy): unify openai-compat (strip) and cliproxy (overlay) launch-settings helpers #1609

Description

@kaitranntt

Summary

Two helpers solve the same root problem (the persisted --settings env block clobbering CCS's runtime routing env) with opposite strategies, and duplicate the temp-dir(0700)/file(0600)/idempotent-cleanup machinery:

  • createOpenAICompatLaunchSettings (utils/openai-compat-launch-settings.ts): strips routing keys so process env wins by absence. Used by settings-flow.ts and delegation/headless-executor.ts (openai-compat profiles).
  • prepareLaunchSettings (cliproxy/executor/launch-settings.ts, added in fix(codex): keep proxy chain authoritative over --settings env #1606): overlays resolved routing values so settings wins by overwrite. Used by the cliproxy interactive launcher.

Why not a trivial merge

Strip and overlay diverge when a key is present in the persisted settings env but absent from process env: strip removes it, overlay keeps it. settings-flow.ts deletes ANTHROPIC_API_KEY from process env and relies on strip to drop it from the temp settings; replacing strip with overlay there would leave a stale key and bypass the proxy auth. Unifying safely needs an explicit "force-absent" key-list parameter on the overlay helper, or restructured callers that pass a fully merged env with deletions represented explicitly.

Scope

Design one canonical helper with an explicit strip-list, migrate all three call sites, and regression-test the openai-compat, settings-flow, and cliproxy paths together. Deferred from the #1606 follow-up because it carries an auth-bypass regression risk and warrants a deliberate, separately reviewed change.

Metadata

Metadata

Assignees

Labels

area:provider-integrationProvider or runtime integration request or bugenhancementNew feature or requestneeds-splitIssue is too broad and should be split into focused issues

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions