from typing import Annotated, TypedDict
from langchain_core.messages import AnyMessage
from langgraph.graph import END, START, StateGraph
from langgraph.graph.message import add_messages
from langgraph.runtime import Runtime
from aion.langgraph import AionContext
class State(TypedDict):
messages: Annotated[list[AnyMessage], add_messages]
async def reply_node(state: State, runtime: Runtime[AionContext]) -> dict:
thread = runtime.context.thread
recent = await thread.history(limit=5)
await thread.reply("I checked the last five messages.")
return {}
builder = StateGraph(State, context_schema=AionContext)
builder.add_node("reply", reply_node)
builder.add_edge(START, "reply")
builder.add_edge("reply", END)
graph = builder.compile()