Python: [BREAKING] Update Agent Framework Lab Lightning to use Agent-lightning v0.2.0 API (#1644)

* Merge changes from AGL release

* Merge changes from AGL release

* fix mypy

* fix tool call with pydantic

* Apply suggestion from @ekzhu

* fix lint

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
Yuge Zhang
2025-10-24 17:02:56 +00:00
committed by GitHub
co-authored by Eric Zhu
parent 73eb00b37b
commit 458819a12b
8 changed files with 3495 additions and 3330 deletions
@@ -7,14 +7,13 @@ from unittest.mock import AsyncMock, patch
import pytest
from agent_framework import (
AgentExecutor,
AgentRunEvent,
ChatAgent,
WorkflowBuilder,
)
from agent_framework._workflows._events import AgentRunEvent
from agent_framework.lab.lightning import AgentFrameworkTracer
from agent_framework.openai import OpenAIChatClient
from agent_framework_lab_lightning import init
from agentlightning.adapter import TraceTripletAdapter
from agentlightning.tracer import AgentOpsTracer
from agentlightning import TracerTraceToTriplet
from openai.types.chat import ChatCompletion, ChatCompletionMessage
from openai.types.chat.chat_completion import Choice
@@ -134,30 +133,30 @@ async def test_observability(workflow_two_agents):
| |
[chat gpt-4o] [chat gpt-4o]
"""
init()
tracer = AgentOpsTracer()
tracer = AgentFrameworkTracer()
try:
tracer.init()
tracer.init_worker(0)
with tracer.trace_context():
async with tracer.trace_context():
await workflow_two_agents.run("Please analyze the quarterly sales data")
triplets = TraceTripletAdapter(agent_match=None, llm_call_match="chat").adapt(tracer.get_last_trace())
triplets = TracerTraceToTriplet(agent_match=None, llm_call_match="chat").adapt(tracer.get_last_trace())
assert len(triplets) == 2
triplets = TraceTripletAdapter(agent_match="analyzer", llm_call_match="chat").adapt(tracer.get_last_trace())
triplets = TracerTraceToTriplet(agent_match="analyzer", llm_call_match="chat").adapt(tracer.get_last_trace())
assert len(triplets) == 1
triplets = TraceTripletAdapter(agent_match="advisor", llm_call_match="chat").adapt(tracer.get_last_trace())
triplets = TracerTraceToTriplet(agent_match="advisor", llm_call_match="chat").adapt(tracer.get_last_trace())
assert len(triplets) == 1
# Parent agent is not matched
triplets = TraceTripletAdapter(agent_match="DataAnalyzer", llm_call_match="chat").adapt(tracer.get_last_trace())
triplets = TracerTraceToTriplet(agent_match="DataAnalyzer", llm_call_match="chat").adapt(
tracer.get_last_trace()
)
assert len(triplets) == 0
triplets = TraceTripletAdapter(agent_match="InvestmentAdvisor|advisor", llm_call_match="chat").adapt(
triplets = TracerTraceToTriplet(agent_match="InvestmentAdvisor|advisor", llm_call_match="chat").adapt(
tracer.get_last_trace()
)
assert len(triplets) == 1