Skip to content

Commit ff09054

Browse files
committed
feat(bench-runner): add support for extra HTTP headers in LLM requests
Introduced a new command-line argument `--llm-header` to allow users to specify extra HTTP headers for the LLM endpoint. These headers can be repeated and are parsed into key-value pairs for use in LLM requests, enabling better handling of tenancy and attribution headers.
1 parent 37c0195 commit ff09054

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎crates/bench-runner/src/main.rs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ struct Cli {
4343
#[arg(long)]
4444
base_url: Option<String>,
4545

46+
/// Extra HTTP headers for the LLM endpoint, repeatable: `--llm-header "X-Run-Id: abc"`.
47+
/// Used to pass an inference-router/gateway's tenancy + attribution headers
48+
/// (e.g. X-USER-ID, X-WORKSPACE-ID, X-Run-Id). Format "Key: Value" (first ':' splits).
49+
#[arg(long = "llm-header", value_name = "K: V")]
50+
llm_headers: Vec<String>,
51+
4652
/// Context-engine base URL (bare, e.g. http://localhost:8106). When set, the agent gets
4753
/// `codebase_search`/`codebase_graph` (the ON path); when absent it falls back to grep/glob.
4854
#[arg(long)]
@@ -174,14 +180,25 @@ async fn run(cli: &Cli, spec: &TaskSpec) -> RunResult {
174180
None
175181
};
176182

183+
// Parse repeatable `--llm-header "Key: Value"` flags into (name, value) pairs.
184+
// Forwarded verbatim with every LLM request (proxy tenancy/attribution headers).
185+
let extra_headers: Vec<(String, String)> = cli
186+
.llm_headers
187+
.iter()
188+
.filter_map(|h| {
189+
h.split_once(':')
190+
.map(|(k, v)| (k.trim().to_string(), v.trim().to_string()))
191+
})
192+
.collect();
193+
177194
let llm = LlmClientConfig {
178195
provider,
179196
base_url,
180197
model: cli.model.clone(),
181198
api_key,
182199
temperature,
183200
max_completion_tokens: None,
184-
extra_headers: vec![],
201+
extra_headers,
185202
thinking: None,
186203
disable_cache_control: false,
187204
};

0 commit comments

Comments
 (0)