Skip to content

feat(openai): configure trusted agent session header - #1205

Merged
i386 merged 2 commits into
mainfrom
agent/configurable-agent-session-header
Aug 8, 2026
Merged

feat(openai): configure trusted agent session header#1205
i386 merged 2 commits into
mainfrom
agent/configurable-agent-session-header

Conversation

@i386

@i386 i386 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

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 optional MESH_AGENT_SESSION_HEADER environment variable and applies it as the trusted header. Existing callers remain unchanged when the variable is absent, and explicit with_agent_session_header configuration 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 -- --check
  • cargo test -p openai-frontend --lib (153 passed)
  • cargo clippy -p openai-frontend --lib --all-targets -- -D warnings

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The OpenAI frontend reads MESH_AGENT_SESSION_HEADER during default configuration. Valid values configure the trusted agent-session header. Missing or invalid values disable header-derived session identity. The README documents the environment variable.

Changes

Trusted Agent Session Header

Layer / File(s) Summary
Environment-based header configuration
crates/openai-frontend/src/router.rs, crates/openai-frontend/README.md
The frontend parses MESH_AGENT_SESSION_HEADER as an HTTP header name, applies valid values to OpenAiFrontendConfig::default, tests valid and invalid names, and documents the variable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Mesh-LLM/mesh-llm#1152: This PR extends the same trusted agent-session header configuration in crates/openai-frontend/src/router.rs.

Suggested reviewers: ndizazzo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: configurable trusted agent session header support in the OpenAI frontend.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/configurable-agent-session-header

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This pull request is currently a draft. Reviews will not take place until the PR is marked as ready for review.

@i386
i386 marked this pull request as ready for review August 8, 2026 19:01
@github-actions
github-actions Bot requested a review from ndizazzo August 8, 2026 19:02
@i386 i386 added the blocker blocking other PRs label Aug 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/openai-frontend/src/router.rs (1)

50-56: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make invalid header configuration observable.

configured_agent_session_header returns None for both an unset variable and an invalid value. A configuration typo therefore silently disables AgentSessionIdentity extraction. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 915e691 and 1d7ce1d.

📒 Files selected for processing (2)
  • crates/openai-frontend/README.md
  • crates/openai-frontend/src/router.rs

i386 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review nit in 7330de1. MESH_AGENT_SESSION_HEADER now distinguishes unset, non-UTF-8, and invalid header values; invalid configuration emits a startup warning instead of silently disabling session identity. Added parser coverage for valid and invalid names. Validation: cargo fmt --all -- --check, cargo test -p openai-frontend --lib (153 passed), and clippy with -D warnings.

@i386
i386 marked this pull request as draft August 8, 2026 19:06

@ndizazzo ndizazzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah perfect, this shoukd help us let models dispatch from codex to other CLI tools

@ndizazzo
ndizazzo marked this pull request as ready for review August 8, 2026 20:33
@github-actions
github-actions Bot requested a review from ndizazzo August 8, 2026 20:33
@i386
i386 merged commit 22ae6ab into main Aug 8, 2026
91 checks passed
@i386
i386 deleted the agent/configurable-agent-session-header branch August 8, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker blocking other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants