From 5e9aac75146e0f7a4fda04f46e061a0914c3f5f8 Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Wed, 4 Mar 2026 13:23:07 +0800 Subject: [PATCH] feat(agent): handle AIMessageChunk content access in copilot streaming Update agent service to properly access content from AIMessageChunk objects during chat model streaming. Instead of using dictionary get method on the chunk, now use getattr to directly access the content attribute, ensuring compatibility with the AIMessageChunk object structure. --- gns3server/agent/gns3_copilot/agent_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gns3server/agent/gns3_copilot/agent_service.py b/gns3server/agent/gns3_copilot/agent_service.py index 4743308f7..a3a9cda56 100644 --- a/gns3server/agent/gns3_copilot/agent_service.py +++ b/gns3server/agent/gns3_copilot/agent_service.py @@ -171,7 +171,8 @@ class AgentService: if event_type == "on_chat_model_stream": # Streaming text content from LLM chunk = data.get("chunk", {}) - content = chunk.get("content", "") + # chunk is AIMessageChunk object, access content directly + content = getattr(chunk, "content", "") if content: return {"type": "content", "content": content}