Analysis: Issue #909
Type: Feature Request
Title: Support environment variables and shell commands in HTTP headers
Current Behavior
In model-registry.ts, the apiKey field supports three resolution patterns via resolveApiKeyConfig():
"!command" - Executes shell command, uses stdout (cached)
- Environment variable name - Checks env var, falls back to literal
- Literal value - Used directly
However, headers values are not resolved and are used as literal strings only.
Requested Behavior
Apply the same resolution logic to each header value, enabling configurations like:
Breaking Change Analysis
Yes, this is technically a breaking change. If a header value happens to match an environment variable name, the behavior changes:
- Before:
{"x-header": "HOME"} → literal "HOME"
- After:
{"x-header": "HOME"} → /Users/username (from env)
However, this edge case is unlikely in practice (header values rarely match env var names by accident), and the new behavior is more useful.
Proposed Implementation
Affected file: packages/coding-agent/src/core/model-registry.ts
Changes:
- Add a helper function to resolve all values in a headers object:
- Update
parseModels() (around line 254) to resolve headers:
- Update
loadBuiltInModels() (around line 196) to resolve override headers:
- Update documentation in
README.md to document header resolution:
Files to Modify