Start LangGraph backend migration foundation

This commit is contained in:
Xin Wang
2026-07-27 17:21:29 +08:00
parent 5c719ed2ea
commit 1c8e9da486
33 changed files with 1859 additions and 86 deletions

30
src/agent/state.py Normal file
View File

@@ -0,0 +1,30 @@
"""Minimal serializable state for the first LangGraph slice."""
from dataclasses import dataclass, field
from typing import Any, Protocol, TypedDict
class AccidentGraphState(TypedDict, total=False):
session_id: str
input_text: str
need_form_update: bool
response_text: str
stage_code: str
form_update: dict[str, Any]
turn_count: int
@dataclass(frozen=True)
class GeneratedTurn:
content: str
form_update: dict[str, Any] = field(default_factory=dict)
class ResponseGenerator(Protocol):
async def generate(self, state: AccidentGraphState) -> GeneratedTurn:
"""Generate one state-prefixed response from graph state."""
...
async def aclose(self) -> None:
"""Release any owned network resources."""
...