Skip to content

Commit 63f30a4

Browse files
Expand Agent Framework native coverage
Add native chat-client tool-call and chat-completions agent paths. The chat-completions agent path covers additional request options emitted by Agent Framework native telemetry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7c21191 commit 63f30a4

3 files changed

Lines changed: 95 additions & 7 deletions

File tree

reference/reports/invoke-agent-internal-span.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@
1414
| --- | --- |
1515
| gen_ai.agent.description | [agent-framework], [autogen] |
1616
| gen_ai.agent.name | [agent-framework], [autogen], [crewai], [google-adk], [openai-agents], [pydantic-ai] |
17-
| gen_ai.agent.version | (none) |
1817
| gen_ai.conversation.id | [google-adk] |
1918
| gen_ai.data_source.id | (none) |
2019
| gen_ai.output.type | (none) |
2120
| gen_ai.request.choice.count | [agent-framework], [crewai], [google-adk] |
22-
| gen_ai.request.model | [agent-framework], [autogen], [crewai], [google-adk], [openai-agents], [pydantic-ai] |
23-
| gen_ai.request.seed | [autogen], [crewai], [pydantic-ai] |
21+
| gen_ai.request.seed | [agent-framework], [autogen], [crewai], [pydantic-ai] |
2422

2523
## Recommended
2624

2725
| Attribute | Supporting Libraries |
2826
| --- | --- |
29-
| gen_ai.request.frequency_penalty | [autogen], [crewai], [google-adk], [pydantic-ai] |
27+
| gen_ai.request.frequency_penalty | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
3028
| gen_ai.request.max_tokens | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
31-
| gen_ai.request.model | [autogen], [crewai], [google-adk], [openai-agents], [pydantic-ai] |
32-
| gen_ai.request.presence_penalty | [autogen], [crewai], [google-adk], [pydantic-ai] |
33-
| gen_ai.request.stop_sequences | [autogen], [crewai], [google-adk], [pydantic-ai] |
29+
| gen_ai.request.model | [agent-framework], [autogen], [crewai], [google-adk], [openai-agents], [pydantic-ai] |
30+
| gen_ai.request.presence_penalty | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
31+
| gen_ai.request.stop_sequences | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
3432
| gen_ai.request.temperature | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
3533
| gen_ai.request.top_p | [agent-framework], [autogen], [crewai], [google-adk], [pydantic-ai] |
3634
| gen_ai.response.finish_reasons | [autogen], [crewai], [google-adk], [openai-agents], [pydantic-ai] |

reference/scenarios/agent-framework/data.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
"gen_ai.operation.name",
88
"gen_ai.output.messages",
99
"gen_ai.request.choice.count",
10+
"gen_ai.request.frequency_penalty",
1011
"gen_ai.request.max_tokens",
1112
"gen_ai.request.model",
13+
"gen_ai.request.presence_penalty",
14+
"gen_ai.request.seed",
15+
"gen_ai.request.stop_sequences",
1216
"gen_ai.request.temperature",
1317
"gen_ai.request.top_p",
1418
"gen_ai.system_instructions",

reference/scenarios/agent-framework/scenario.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,90 @@ def get_weather(
5151
print(f" -> {result.text[:60]}")
5252

5353

54+
async def run_tool_call():
55+
"""Scenario: Agent Framework chat client tool calling with native telemetry."""
56+
from agent_framework import Message, tool
57+
from agent_framework.observability import enable_sensitive_telemetry
58+
from agent_framework.openai import OpenAIChatCompletionClient
59+
60+
print(" [chat_tool_call] chat client with tool calling (native telemetry)")
61+
62+
enable_sensitive_telemetry(force=True)
63+
64+
@tool(approval_mode="never_require")
65+
def get_weather(
66+
location: Annotated[str, "The location to get the weather for."],
67+
) -> str:
68+
"""Get the weather for a given location."""
69+
return f"Sunny in {location}"
70+
71+
client = OpenAIChatCompletionClient(
72+
model="gpt-4o-mini",
73+
base_url=MOCK_BASE_URL,
74+
api_key="mock-key",
75+
)
76+
response = await client.get_response(
77+
[Message(role="user", contents=["What's the weather in Seattle?"])],
78+
options={
79+
"tools": [get_weather],
80+
"temperature": 0.2,
81+
"top_p": 0.9,
82+
"max_tokens": 64,
83+
"seed": 7,
84+
"stop": ["<END>"],
85+
"frequency_penalty": 0.1,
86+
"presence_penalty": 0.2,
87+
},
88+
)
89+
print(f" -> {response.text[:60]}")
90+
91+
92+
async def run_chat_completion_agent_tool_call():
93+
"""Scenario: Agent Framework agent execution through Chat Completions."""
94+
from agent_framework import Agent, tool
95+
from agent_framework.observability import enable_sensitive_telemetry
96+
from agent_framework.openai import OpenAIChatCompletionClient
97+
98+
print(" [agent_chat_completion] agent with Chat Completions (native telemetry)")
99+
100+
enable_sensitive_telemetry(force=True)
101+
102+
@tool(approval_mode="never_require")
103+
def get_weather(
104+
location: Annotated[str, "The location to get the weather for."],
105+
) -> str:
106+
"""Get the weather for a given location."""
107+
return f"Sunny in {location}"
108+
109+
client = OpenAIChatCompletionClient(
110+
model="gpt-4o-mini",
111+
base_url=MOCK_BASE_URL,
112+
api_key="mock-key",
113+
)
114+
agent = Agent(
115+
client=client,
116+
id="weather-agent-chat-completions",
117+
name="WeatherAgentChatCompletions",
118+
description="Answers weather questions with a function tool.",
119+
instructions="You are a helpful weather agent.",
120+
tools=[get_weather],
121+
)
122+
123+
result = await agent.run(
124+
"What's the weather in Seattle?",
125+
options={
126+
"temperature": 0.2,
127+
"top_p": 0.9,
128+
"max_tokens": 64,
129+
"seed": 7,
130+
"stop": ["<END>"],
131+
"frequency_penalty": 0.1,
132+
"presence_penalty": 0.2,
133+
},
134+
)
135+
print(f" -> {result.text[:60]}")
136+
137+
54138
async def run_agent_workflow():
55139
"""Scenario: Agent Framework workflow execution with native telemetry."""
56140
from agent_framework import Agent, WorkflowBuilder
@@ -99,6 +183,8 @@ def main():
99183
tp, lp, mp = setup_otel()
100184

101185
asyncio.run(run_agent_tool_call())
186+
asyncio.run(run_tool_call())
187+
asyncio.run(run_chat_completion_agent_tool_call())
102188
asyncio.run(run_agent_workflow())
103189

104190
flush_and_shutdown(tp, lp, mp)

0 commit comments

Comments
 (0)