What
Propagate the calling AI agent's session id (and trace id when present) into ClickHouse Cloud API request headers, so backend telemetry can correlate every clickhousectl call made within a single agent session/conversation.
Why
We already detect the agent and tag the User-Agent (agent=claude-code) via is-ai-agent. The new is-ai-agent v0.4.0 adds Agent::session_id and Agent::traceparent / Agent::trace_id(), exposing the per-session identifier the agent publishes to its subprocesses (e.g. CLAUDE_CODE_SESSION_ID). Forwarding this lets the backend group calls by agent run — e.g. see how a single Claude Code session's requests correlate.
How (sketch — impl details for the implementing agent)
- Bump
is-ai-agent 0.2.1 → 0.4.0 in crates/clickhousectl/Cargo.toml.
- In
CloudClient::new() (crates/clickhousectl/src/cloud/client.rs), attach the ids as default headers on the reqwest client we build. Both the management API and SQL query paths reuse that self.http, so default headers cover everything — no clickhouse-cloud-api library changes needed.
- Header names the backend looks for:
agent-session-id ← Agent::session_id
traceparent ← Agent::traceparent (raw W3C value)
- Guard header values with
HeaderValue::from_str(..).ok() (session ids are opaque vendor strings).
- Tests: a pure-logic header-builder unit test (inject a fake
Agent), optionally extend tests/cli_request_shape_test.rs to assert headers land on the wire.
What
Propagate the calling AI agent's session id (and trace id when present) into ClickHouse Cloud API request headers, so backend telemetry can correlate every
clickhousectlcall made within a single agent session/conversation.Why
We already detect the agent and tag the User-Agent (
agent=claude-code) viais-ai-agent. The newis-ai-agentv0.4.0 addsAgent::session_idandAgent::traceparent/Agent::trace_id(), exposing the per-session identifier the agent publishes to its subprocesses (e.g.CLAUDE_CODE_SESSION_ID). Forwarding this lets the backend group calls by agent run — e.g. see how a single Claude Code session's requests correlate.How (sketch — impl details for the implementing agent)
is-ai-agent0.2.1→0.4.0incrates/clickhousectl/Cargo.toml.CloudClient::new()(crates/clickhousectl/src/cloud/client.rs), attach the ids as default headers on the reqwest client we build. Both the management API and SQL query paths reuse thatself.http, so default headers cover everything — noclickhouse-cloud-apilibrary changes needed.agent-session-id←Agent::session_idtraceparent←Agent::traceparent(raw W3C value)HeaderValue::from_str(..).ok()(session ids are opaque vendor strings).Agent), optionally extendtests/cli_request_shape_test.rsto assert headers land on the wire.