Skip to content

Agent framework extension update for input and output attributes#154

Merged
nikhilNava merged 2 commits intomainfrom
nikhilc/Auto-agent-framework-attributes
Feb 3, 2026
Merged

Agent framework extension update for input and output attributes#154
nikhilNava merged 2 commits intomainfrom
nikhilc/Auto-agent-framework-attributes

Conversation

@nikhilNava
Copy link
Contributor

Task
Update the agent framework extension to support all attributes

Solution

{
    "name": "chat gpt-4o-mini",
    "context": {
        "trace_id": "0xf94fcbdcf4f6abb66d3f9ba08fec4552",
        "span_id": "0xaf48669303a239d7",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": "0xe0adb0217fb3f9ee",
    "start_time": "2026-02-03T13:48:57.250597Z",
    "end_time": "2026-02-03T13:48:58.624052Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "operation.source": "SDK",
        "tenant.id": "badf1f56-284d-4dc5-ac59-0dd53900e743",
        "correlation.id": "agent-framework-correlation-id",
        "gen_ai.conversation.id": "ca71ab1d-3dae-4ba8-bef6-bb10a762dbf5",
        "gen_ai.agent.id": "a70248c0-9daa-4b4a-a498-b3c95c8422a5",
        "gen_ai.agent.name": "Perplexity02 Agent",
        "gen_ai.agent.upn": "Sample Agent UPN",
        "gen_ai.agent.applicationid": "agent-framework-sample-blueprint",
        "gen_ai.caller.client.ip": "0.0.0.0",
        "gen_ai.channel.name": "msteams",
        "gen_ai.input.messages": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Compute 15 % 4\"}]}]",
        "gen_ai.operation.name": "chat",
        "gen_ai.request.choice.count": 1,
        "gen_ai.provider.name": "azure.ai.openai",
        "gen_ai.request.model": "gpt-4o-mini",
        "server.address": "https://nikhilc-aoai.cognitiveservices.azure.com/openai/deployments/gpt-4o-mini/",
        "gen_ai.tool.definitions": "[{\"type\": \"function\", \"function\": {\"name\": \"get_weather\", \"description\": \"Get the current weather for a specified location\", \"parameters\": {\"properties\": {\"location\": {\"description\": \"The city and state/country to get weather for, e.g., 'Seattle, WA'\", \"title\": \"Location\", \"type\": \"string\"}}, \"required\": [\"location\"], \"title\": \"get_weather_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"calculate\", \"description\": \"Calculate the result of a mathematical expression\", \"parameters\": {\"properties\": {\"expression\": {\"description\": \"The mathematical expression to evaluate, e.g., '2 + 2' or 'sqrt(16)'\", \"title\": \"Expression\", \"type\": \"string\"}}, \"required\": [\"expression\"], \"title\": \"calculate_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"get_current_time\", \"description\": \"Get the current date and time\", \"parameters\": {\"properties\": {\"timezone\": {\"default\": \"UTC\", \"description\": \"The timezone to get the time for, e.g., 'UTC', 'US/Eastern', 'Europe/London'\", \"title\": \"Timezone\", \"type\": \"string\"}}, \"title\": \"get_current_time_input\", \"type\": \"object\"}}}]",
        "gen_ai.response.id": "chatcmpl-D5B3yliLfQoJLtIZ1XRh7PdMxHy7t",
        "gen_ai.response.finish_reasons": "[\"tool_calls\"]",
        "gen_ai.response.model": "gpt-4o-mini-2024-07-18",
        "gen_ai.usage.input_tokens": 282,
        "gen_ai.usage.output_tokens": 17,
        "gen_ai.client.operation.duration": 1.3721860999939963,
        "gen_ai.output.messages": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"tool_call\", \"id\": \"call_sC3R47BGlUkeo2PLQCZSiRRf\", \"name\": \"calculate\", \"arguments\": \"{\\\"expression\\\":\\\"15 % 4\\\"}\"}], \"finish_reason\": \"tool_call\"}]"
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.38.0",
            "service.namespace": "AgentFrameworkSample",
            "service.name": "AgentFrameworkTracing"
        },
        "schema_url": ""
    }
}
{
    "name": "execute_tool calculate",
    "context": {
        "trace_id": "0xf94fcbdcf4f6abb66d3f9ba08fec4552",
        "span_id": "0x5b3463d644cb67ac",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": "0xe0adb0217fb3f9ee",
    "start_time": "2026-02-03T13:48:58.624052+00:00",
    "end_time": "2026-02-03T13:48:58.624052+00:00",
    "status": {
        "status_code": "StatusCode.UNSET",
        "description": null
    },
    "attributes": {
        "gen_ai.operation.name": "execute_tool",
        "gen_ai.tool.name": "calculate",
        "gen_ai.tool.call.id": "call_sC3R47BGlUkeo2PLQCZSiRRf",
        "gen_ai.tool.type": "function",
        "gen_ai.tool.description": "Calculate the result of a mathematical expression",
        "gen_ai.tool.call.arguments": "{\"expression\":\"15 % 4\"}",
        "operation.source": "SDK",
        "tenant.id": "badf1f56-284d-4dc5-ac59-0dd53900e743",
        "correlation.id": "agent-framework-correlation-id",
        "gen_ai.conversation.id": "ca71ab1d-3dae-4ba8-bef6-bb10a762dbf5",
        "gen_ai.agent.id": "a70248c0-9daa-4b4a-a498-b3c95c8422a5",
        "gen_ai.agent.name": "Perplexity02 Agent",
        "gen_ai.agent.upn": "Sample Agent UPN",
        "gen_ai.agent.applicationid": "agent-framework-sample-blueprint",
        "gen_ai.caller.client.ip": "0.0.0.0",
        "gen_ai.channel.name": "msteams",
        "gen_ai.tool.call.result": "\"The result of 15 % 4 is 3\"",
        "agent_framework.function.invocation.duration": 0.00011819999781437218,     
        "gen_ai.tool.arguments": "{\"expression\":\"15 % 4\"}",
        "gen_ai.event.content": "\"The result of 15 % 4 is 3\""
    },
    "events": null,
    "links": null,
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.38.0",
        "service.namespace": "AgentFrameworkSample",
        "service.name": "AgentFrameworkTracing"
    }
}
{
    "name": "chat gpt-4o-mini",
    "context": {
        "trace_id": "0xf94fcbdcf4f6abb66d3f9ba08fec4552",
        "span_id": "0xe9ab4305e19d44bc",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": "0xe0adb0217fb3f9ee",
    "start_time": "2026-02-03T13:48:58.628136Z",
    "end_time": "2026-02-03T13:48:59.299824Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "operation.source": "SDK",
        "tenant.id": "badf1f56-284d-4dc5-ac59-0dd53900e743",
        "correlation.id": "agent-framework-correlation-id",
        "gen_ai.conversation.id": "ca71ab1d-3dae-4ba8-bef6-bb10a762dbf5",
        "gen_ai.agent.id": "a70248c0-9daa-4b4a-a498-b3c95c8422a5",
        "gen_ai.agent.name": "Perplexity02 Agent",
        "gen_ai.agent.upn": "Sample Agent UPN",
        "gen_ai.agent.applicationid": "agent-framework-sample-blueprint",
        "gen_ai.caller.client.ip": "0.0.0.0",
        "gen_ai.channel.name": "msteams",
        "gen_ai.input.messages": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Compute 15 % 4\"}]}, {\"role\": \"assistant\", \"parts\": [{\"type\": \"tool_call\", \"id\": \"call_sC3R47BGlUkeo2PLQCZSiRRf\", \"name\": \"calculate\", \"arguments\": \"{\\\"expression\\\":\\\"15 % 4\\\"}\"}]}, {\"role\": \"tool\", \"parts\": [{\"type\": \"tool_call_response\", \"id\": \"call_sC3R47BGlUkeo2PLQCZSiRRf\", \"response\": \"\\\"The result of 15 % 4 is 3\\\"\"}]}]",
        "gen_ai.operation.name": "chat",
        "gen_ai.request.choice.count": 1,
        "gen_ai.provider.name": "azure.ai.openai",
        "gen_ai.request.model": "gpt-4o-mini",
        "server.address": "https://nikhilc-aoai.cognitiveservices.azure.com/openai/deployments/gpt-4o-mini/",
        "gen_ai.tool.definitions": "[{\"type\": \"function\", \"function\": {\"name\": \"get_weather\", \"description\": \"Get the current weather for a specified location\", \"parameters\": {\"properties\": {\"location\": {\"description\": \"The city and state/country to get weather for, e.g., 'Seattle, WA'\", \"title\": \"Location\", \"type\": \"string\"}}, \"required\": [\"location\"], \"title\": \"get_weather_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"calculate\", \"description\": \"Calculate the result of a mathematical expression\", \"parameters\": {\"properties\": {\"expression\": {\"description\": \"The mathematical expression to evaluate, e.g., '2 + 2' or 'sqrt(16)'\", \"title\": \"Expression\", \"type\": \"string\"}}, \"required\": [\"expression\"], \"title\": \"calculate_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"get_current_time\", \"description\": \"Get the current date and time\", \"parameters\": {\"properties\": {\"timezone\": {\"default\": \"UTC\", \"description\": \"The timezone to get the time for, e.g., 'UTC', 'US/Eastern', 'Europe/London'\", \"title\": \"Timezone\", \"type\": \"string\"}}, \"title\": \"get_current_time_input\", \"type\": \"object\"}}}]",
        "gen_ai.response.id": "chatcmpl-D5B3y8XS5hWPhYvdbzA35rughgqzk",
        "gen_ai.response.finish_reasons": "[\"stop\"]",
        "gen_ai.response.model": "gpt-4o-mini-2024-07-18",
        "gen_ai.usage.input_tokens": 316,
        "gen_ai.usage.output_tokens": 18,
        "gen_ai.client.operation.duration": 0.6709190999972634,
        "gen_ai.output.messages": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"text\", \"content\": \"The result of \\\\( 15 \\\\mod 4 \\\\) is 3.\"}], \"finish_reason\": \"stop\"}]"
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.38.0",
            "service.namespace": "AgentFrameworkSample",
            "service.name": "AgentFrameworkTracing"
        },
        "schema_url": ""
    }
}
{
    "name": "invoke_agent Agent365Assistant",
    "context": {
        "trace_id": "0xf94fcbdcf4f6abb66d3f9ba08fec4552",
        "span_id": "0xe0adb0217fb3f9ee",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": null,
    "start_time": "2026-02-03T13:48:57.244472+00:00",
    "end_time": "2026-02-03T13:48:59.301878+00:00",
    "status": {
        "status_code": "StatusCode.UNSET",
        "description": null
    },
    "attributes": {
        "operation.source": "SDK",
        "tenant.id": "badf1f56-284d-4dc5-ac59-0dd53900e743",
        "correlation.id": "agent-framework-correlation-id",
        "gen_ai.conversation.id": "ca71ab1d-3dae-4ba8-bef6-bb10a762dbf5",
        "gen_ai.agent.upn": "Sample Agent UPN",
        "gen_ai.agent.applicationid": "agent-framework-sample-blueprint",
        "gen_ai.caller.client.ip": "0.0.0.0",
        "gen_ai.channel.name": "msteams",
        "gen_ai.caller.id": "a92962f3-9ed4-4bcd-9ae0-ad0002b6ca76",
        "gen_ai.caller.name": "Alex Wilber",
        "gen_ai.caller.upn": "Sample UPN",
        "gen_ai.input.messages": "[\"Compute 15 % 4\"]",
        "gen_ai.operation.name": "invoke_agent",
        "gen_ai.request.choice.count": 1,
        "gen_ai.provider.name": "microsoft.agent_framework",
        "gen_ai.request.model": "unknown",
        "gen_ai.tool.definitions": "[{\"type\": \"function\", \"function\": {\"name\": \"get_weather\", \"description\": \"Get the current weather for a specified location\", \"parameters\": {\"properties\": {\"location\": {\"description\": \"The city and state/country to get weather for, e.g., 'Seattle, WA'\", \"title\": \"Location\", \"type\": \"string\"}}, \"required\": [\"location\"], \"title\": \"get_weather_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"calculate\", \"description\": \"Calculate the result of a mathematical expression\", \"parameters\": {\"properties\": {\"expression\": {\"description\": \"The mathematical expression to evaluate, e.g., '2 + 2' or 'sqrt(16)'\", \"title\": \"Expression\", \"type\": \"string\"}}, \"required\": [\"expression\"], \"title\": \"calculate_input\", \"type\": \"object\"}}}, {\"type\": \"function\", \"function\": {\"name\": \"get_current_time\", \"description\": \"Get the current date and time\", \"parameters\": {\"properties\": {\"timezone\": {\"default\": \"UTC\", \"description\": \"The timezone to get the time for, e.g., 'UTC', 'US/Eastern', 'Europe/London'\", \"title\": \"Timezone\", \"type\": \"string\"}}, \"title\": \"get_current_time_input\", \"type\": \"object\"}}}]",
        "gen_ai.agent.id": "6ee426ca-56ae-4b9d-be78-c822bd1f6f8a",
        "gen_ai.agent.name": "Agent365Assistant",
        "gen_ai.agent.description": "A helpful AI assistant powered by Microsoft Agent Framework",
        "gen_ai.response.id": "chatcmpl-D5B3y8XS5hWPhYvdbzA35rughgqzk",
        "gen_ai.response.finish_reasons": "[\"stop\"]",
        "gen_ai.usage.input_tokens": 316,
]"
    },
    "events": null,
    "links": null,
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.38.0",
        "service.namespace": "AgentFrameworkSample",
        "service.name": "AgentFrameworkTracing"
    }
}

@nikhilNava nikhilNava requested a review from a team as a code owner February 3, 2026 14:13
Copilot AI review requested due to automatic review settings February 3, 2026 14:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Agent Framework observability extension to better normalize GenAI span attributes—especially input/output message content and tool call fields—by adding an on-end span enricher.

Changes:

  • Added message-parsing utilities to extract text content from Agent Framework-style messages JSON.
  • Introduced an Agent Framework span enricher that (a) extracts input/output message content and (b) maps tool call arguments/results to standard keys.
  • Updated the Agent Framework instrumentor to register/unregister the span enricher during instrument/uninstrument, and updated the extension public API export.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.../agentframework/utils.py Adds JSON message parsing helpers for extracting text-only content.
.../agentframework/span_enricher.py Adds an on-end enricher to normalize message and tool-call attributes before export.
.../agentframework/trace_instrumentor.py Registers/unregisters the span enricher and updates instrumentation dependency requirement.
.../agentframework/span_processor.py Minor import/constant ordering cleanup.
.../agentframework/__init__.py Exposes AgentFrameworkInstrumentor as part of the extension’s public API.

@nikhilNava nikhilNava enabled auto-merge (squash) February 3, 2026 14:56
@nikhilNava nikhilNava merged commit 2ef3d3c into main Feb 3, 2026
8 checks passed
@nikhilNava nikhilNava deleted the nikhilc/Auto-agent-framework-attributes branch February 3, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments