core Package

Modules

agent_details
apply_guardrail_scope

OpenTelemetry tracing scope for guardrail (security guardian) evaluations.

channel
constants
enricher_utils

Shared utilities for A365 span enrichers.

Provides content extraction helpers used by framework-specific enrichers (Agent Framework, Semantic Kernel, LangChain) to convert structured OTel messages to plain content arrays before A365 export.

execute_tool_scope
guardrail_decision_type

String constants for guardrail decision types.

guardrail_details

Data class for guardrail evaluation details.

guardrail_finding

Data class for a single guardrail security finding.

guardrail_risk_severity

String constants for guardrail risk severity levels.

guardrail_target_type

String constants for guardrail target types.

inference_call_details
inference_operation_type
inference_scope
invoke_agent_details
invoke_agent_scope
message_utils

Conversion and serialization helpers for OTEL gen-ai message format.

Provides normalization from plain list[str] (backward compat) to the structured array format, and a non-throwing serialize_messages function.

opentelemetry_scope
request
span_details
tool_call_details
tool_type
utils

Classes

AgentDetails

Details about an AI agent in the system.

ApplyGuardrailScope

Provides OpenTelemetry tracing scope for security guardrail evaluations.

Guardian spans SHOULD be children of the operation span they are protecting (e.g., inference or execute_tool spans). Multiple guardian spans MAY exist under a single operation span if multiple guardians are chained.

Example usage:


   from microsoft.opentelemetry.a365.core import (
       ApplyGuardrailScope, GuardrailDetails, AgentDetails,
       GuardrailDecisionType, GuardrailTargetType, GuardrailRiskSeverity,
       GuardrailFinding,
   )

   details = GuardrailDetails(
       target_type=GuardrailTargetType.LLM_INPUT,
       decision_type=GuardrailDecisionType.ALLOW,
       guardian_name="Azure Content Safety",
   )

   with ApplyGuardrailScope.start(details, agent_details) as scope:
       # ... run guardrail evaluation ...
       scope.record_finding(GuardrailFinding(
           risk_category="hate_speech",
           risk_severity=GuardrailRiskSeverity.HIGH,
           risk_score=0.95,
       ))
       scope.record_decision(GuardrailDecisionType.DENY, "Blocked by policy")

Initialize the guardrail scope.

BaggageBuilder

Per request baggage builder.

This class provides a fluent API for setting baggage values that will be propagated in the OpenTelemetry context.

Initialize the baggage builder.

BlobPart

Inline binary data (base64-encoded).

CallerDetails

Composite caller details for agent-to-agent (A2A) scenarios.

Groups the human caller identity and the calling agent identity together.

Channel

Channel information for agent execution context.

ChatMessage

An input message sent to a model (OTEL gen-ai semantic conventions).

ExecuteToolScope

Provides OpenTelemetry tracing scope for AI tool execution operations.

Initialize the tool execution scope.

FilePart

Reference to a pre-uploaded file.

GenericPart

Extensible part for custom / future types.

GuardrailDecisionType

Well-known guardrail decision type values.

GuardrailDetails

Immutable input contract describing a guardrail evaluation.

GuardrailFinding

A single security finding from a guardrail evaluation.

GuardrailRiskSeverity

Well-known risk severity level values.

GuardrailTargetType

Well-known guardrail target type values.

Users may also supply custom string values not listed here.

InferenceCallDetails

Details of an inference call for generative AI operations.

InferenceScope

Provides OpenTelemetry tracing scope for generative AI inference operations.

Initialize the inference scope.

InputMessages

Container for input messages. Serializes as a plain JSON array per OTel spec.

InvokeAgentScope

Provides OpenTelemetry tracing scope for AI agent invocation operations.

Initialize the agent invocation scope.

InvokeAgentScopeDetails

Scope-level configuration for agent invocation tracing.

OpenTelemetryScope

Base class for OpenTelemetry tracing scopes in the SDK.

Initialize the OpenTelemetry scope.

OutputMessage

An output message produced by a model (OTEL gen-ai semantic conventions).

finish_reason defaults to "stop" per OTel spec when not provided.

OutputMessages

Container for output messages. Serializes as a plain JSON array per OTel spec.

OutputScope

Provides OpenTelemetry tracing scope for output messages.

Output messages are set once (via the constructor or record_output_messages) rather than accumulated. For streaming scenarios, the agent developer should collect all output (e.g. via a list or string builder) and pass the final result to OutputScope.

Initialize the output scope.

ReasoningPart

Model reasoning / chain-of-thought content.

Request

Request details for agent execution.

Response

Response details from agent execution.

Accepts plain strings (backward compat), structured OutputMessages, or a dict for tool call results (per OTEL spec).

ServerToolCallPart

Server-side tool invocation.

ServerToolCallResponsePart

Server-side tool response.

ServiceEndpoint

Represents a service endpoint with hostname and optional port.

SpanDetails

Groups span configuration for scope construction.

TextPart

Plain text content.

ToolCallDetails

Details of a tool call made by an agent in the system.

ToolCallRequestPart

A tool call requested by the model.

ToolCallResponsePart

Result of a tool call.

UriPart

External URI reference.

UserDetails

Details about the human user that invoked an agent.

Enums

FinishReason

Reason a model stopped generating per OTEL gen-ai semantic conventions.

InferenceOperationType

Supported inference operation types for generative AI.

MessageRole

Role of a message participant per OTEL gen-ai semantic conventions.

Modality

Media modality for blob, file, and URI parts.

ToolType

Enumeration for different tool types for execute tool contexts.