Repository navigation
feat: a shared tool server names its own header variables, for a credential that differs per rollout - #3012
Open
faresobeid wants to merge 1 commit into
Open
feat: a shared tool server names its own header variables, for a credential that differs per rollout#3012faresobeid wants to merge 1 commit into
faresobeid wants to merge 1 commit into
Conversation
…ential that differs per rollout SharedToolServer.header_env joins the harness config's mcp_header_env for the rollouts given that server, so callers that sign each rollout into a server as its own account need no copy of the agent per rollout.
faresobeid
marked this pull request as ready for review
October 30, 2026 14:03
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Shared tool servers can now specify host-environment header variables for a rollout-local harness copy. The mapping defaults to empty and reuses existing credential resolution, leaving ordinary rollouts unchanged. You can add or adjust custom eligibility rules. Learn more. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SharedToolServer.header_env: the MCP headers a harness sends that server, each read from a named host env var, asHarnessConfig.mcp_header_envnames them. A rollout given that server sends them, merged into a copy of its harness's config (the server's win, header by header).Why:
mcp_header_envlives on the harness config, so it is the same for every rollout of an agent. A caller that signs each rollout into a server as its own account (worlds: each agent of a swarm is its own account on the team world, and the server enforces what each may do) needs a different variable per rollout. Today that means a copy of the agent per rollout with its own harness config: worlds re-runsAgent.__init__on a copy and restores_gate,trainableand_warned_resourcesby hand, which breaks silently when the agent gains another private field (its rollouts would stop reaching the trainer). With this, one agent serves every rollout, and each rollout's server carries its own variable name:Secrets: unchanged. Only variable names are held, as with
mcp_header_env; values are read from the host env when the harness session starts, and never enter a config, a task or a trace.SharedToolServeris a live object passed torun, never serialized.The change
SharedToolServer.header_env(mcp/launch.py), default empty.Harness.with_mcp_header_env(header_env)(harness.py): a shallow copy whose config'smcp_header_envalso names them.Rolloutuses that copy when any shared server hasheader_env(rollout.py), so every harness that readsself.config.mcp_header_env(ACP, hermes) gets it without new parameters.Checked:
tests/unit/harnesses/test_header_env.py(merge, precedence, resolution from the env, no value in the config's dump).uv run pytest tests/unit -n auto: passed (Docker, Prime and harbor tests skipped).ruff check,ruff format --checkpass.Related: #2915 (
Agent.with_config) solves the per-rollout copy in general; this removes the need for it in the per-rollout-credential case.🤖 Generated with Claude Code
Note
Let shared tool servers name their own MCP header env variables
header_envfield toSharedToolServerin launch.py that maps header names to host environment-variable namesHarness.with_mcp_header_envin harness.py, which returns a copied harness whose config merges these mappings intomcp_header_env; supplied header keys override existing ones for a server present in bothRollout.__init__in rollout.py collects nonemptyheader_envmappings from shared tools and swaps in the merged harness when any existheader_envnow run on a copied harness; the original harness config is never mutatedMacroscope summarized dcab198.
Note
Medium Risk
Changes how rollout-scoped MCP credentials are wired (auth-sensitive), but keeps the existing name-only config model and isolates per-rollout state via harness copies rather than mutating the agent.
Overview
Rollouts can now supply different MCP auth headers per shared tool server without cloning the whole agent/harness config.
SharedToolServergains optionalheader_env: header name → host environment variable name (values still resolved at session start, not stored in config or traces).Harness.with_mcp_header_envreturns a shallow harness copy whosemcp_header_envmerges these mappings; keys from the shared server override the base config header-by-header, and the original harness is unchanged.Rolloutcollects nonemptyheader_envfrom passed-in shared tools and runs on the merged harness copy so existing harness paths that callresolve_mcp_headerspick up rollout-specific credentials automatically.A unit test covers merge precedence, env resolution, and that resolved secret values never appear in serialized config.
Reviewed by Cursor Bugbot for commit dcab198. Bugbot is set up for automated code reviews on this repo. Configure here.