feat(openai): configure trusted agent session header - #1205
Conversation
📝 WalkthroughWalkthroughThe OpenAI frontend reads ChangesTrusted Agent Session Header
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request is currently a draft. Reviews will not take place until the PR is marked as ready for review. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/openai-frontend/src/router.rs (1)
50-56: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMake invalid header configuration observable.
configured_agent_session_headerreturnsNonefor both an unset variable and an invalid value. A configuration typo therefore silently disablesAgentSessionIdentityextraction. Emit a startup warning or make invalid configuration fail during construction. Add coverage for absent, invalid, and valid values.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/openai-frontend/src/router.rs` around lines 50 - 56, Update configured_agent_session_header to distinguish an unset MESH_AGENT_SESSION_HEADER from an invalid header value, emitting a startup warning or failing during router construction for invalid configuration while preserving None for absent configuration. Add coverage covering absent, invalid, and valid environment values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/openai-frontend/src/router.rs`:
- Around line 50-56: Update configured_agent_session_header to distinguish an
unset MESH_AGENT_SESSION_HEADER from an invalid header value, emitting a startup
warning or failing during router construction for invalid configuration while
preserving None for absent configuration. Add coverage covering absent, invalid,
and valid environment values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3554fa11-b05b-480f-a518-0cc50fa317d3
📒 Files selected for processing (2)
crates/openai-frontend/README.mdcrates/openai-frontend/src/router.rs
|
Addressed the review nit in 7330de1. |
ndizazzo
left a comment
There was a problem hiding this comment.
Ah perfect, this shoukd help us let models dispatch from codex to other CLI tools
Problem
The OpenAI frontend supports a configurable trusted agent-session header, but the default router ignored that configuration. A Mesh process launched with a trusted upstream session-header setting therefore treated every request as stateless.
Change
OpenAiFrontendConfig::default()now reads the optionalMESH_AGENT_SESSION_HEADERenvironment variable and applies it as the trusted header. Existing callers remain unchanged when the variable is absent, and explicitwith_agent_session_headerconfiguration still takes precedence.Invalid or non-UTF-8 values emit a startup warning and are ignored rather than silently looking like a valid configuration. Parser coverage covers valid and invalid names.
This keeps the boundary generic: Mesh does not hard-code Cacheline or a benchmark-specific header name.
Validation
cargo fmt --all -- --checkcargo test -p openai-frontend --lib(153 passed)cargo clippy -p openai-frontend --lib --all-targets -- -D warnings