Fix MCP transport compatibility and batch_store e2e coverage

This commit is contained in:
Agent Zero
2026-03-22 03:18:08 +00:00
parent d7140eb7f3
commit 26c96b41dd
5 changed files with 329 additions and 15 deletions

View File

@@ -90,6 +90,15 @@ pub fn get_optional_agent_id(headers: &HeaderMap) -> Option<String> {
.map(ToOwned::to_owned)
}
pub fn get_optional_agent_type(headers: &HeaderMap) -> Option<String> {
headers
.get("X-Agent-Type")
.and_then(|v| v.to_str().ok())
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned)
}
/// Extract agent ID from request headers or default
pub fn get_agent_id(request: &Request) -> String {
get_optional_agent_id(request.headers())
@@ -122,4 +131,15 @@ mod tests {
Some("agent-zero")
);
}
#[test]
fn extracts_agent_type_from_header() {
let mut headers = HeaderMap::new();
headers.insert("X-Agent-Type", HeaderValue::from_static("codex"));
assert_eq!(
get_optional_agent_type(&headers).as_deref(),
Some("codex")
);
}
}