feat(autogen-core): add gen_ai.agent.action_ref to trace_tool_span for cross-producer audit correlation#7893
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends autogen_core’s GenAI OpenTelemetry instrumentation to support cross-producer audit correlation by introducing a new span attribute (gen_ai.agent.action_ref) and providing a helper to deterministically derive that value.
Changes:
- Added
GEN_AI_AGENT_ACTION_REF = "gen_ai.agent.action_ref"semantic-convention constant. - Added
derive_action_ref(...)helper to compute a deterministic SHA-256 hex digest from canonicalized JSON input fields. - Extended
trace_tool_span(...)with an optionalaction_refparameter and emits it as a span attribute when provided.
| Produces a SHA-256 hex digest from RFC 8785 JCS canonical JSON of the | ||
| four preimage fields. Any implementation using the same inputs yields | ||
| the same 32-byte hex string, enabling cross-producer correlation without | ||
| shared state. |
| preimage = json.dumps( | ||
| { | ||
| "agent_id": agent_id, | ||
| "action_type": action_type, | ||
| "scope": scope, | ||
| "timestamp_ms": timestamp_ms, | ||
| }, | ||
| sort_keys=True, | ||
| separators=(",", ":"), | ||
| ) | ||
| return hashlib.sha256(preimage.encode()).hexdigest() |
@microsoft-github-policy-service agree |
Adds an optional �ction_ref parameter and a derive_action_ref() helper to race_tool_span().
Changes:
Properties:
Closes #7850