test(api): Add extended agent stream tests and fix type annotations

This commit is contained in:
Yunxiao Xu
2026-02-15 18:52:26 -08:00
parent 5b9d644fe5
commit 1cf00d0b3f
2 changed files with 162 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ import base64
from langchain_core.runnables.config import RunnableConfig
from langchain_core.messages import BaseMessage
from ea_chatbot.graph.state import AgentState
router = APIRouter(prefix="/chat", tags=["agent"])
async def stream_agent_events(
@@ -27,7 +29,7 @@ async def stream_agent_events(
Generator that invokes the LangGraph agent and yields SSE formatted events.
Persists assistant responses and plots to the database.
"""
initial_state = {
initial_state: AgentState = {
"messages": messages,
"question": message,
"summary": summary,
@@ -38,7 +40,8 @@ async def stream_agent_events(
"code_output": None,
"error": None,
"plots": [],
"dfs": {}
"dfs": {},
"iterations": 0
}
config: RunnableConfig = {"configurable": {"thread_id": thread_id}}