logic_assistant / src /agent /state.py
anhkhoiphan's picture
Deploy: add Dockerfile, app.py, agent/memory/tools modules
f82d2d7
Raw
History Blame Contribute Delete
1.08 kB
from __future__ import annotations
from typing import Annotated
from typing_extensions import TypedDict
from langchain_core.messages import BaseMessage
try:
from langgraph.graph.message import add_messages
except ImportError:
from langgraph.graph import add_messages
class AgentState(TypedDict, total=False):
# Conversation history — append-only via add_messages reducer
messages: Annotated[list[BaseMessage], add_messages]
# Set on session start, carried through every turn
session_id: str
# Rolling summary of old messages (updated when history grows too long)
conversation_summary: str
# Raw graph payload (contains copyrighted definitions)
# Populated by masker_node after graph tool calls finish
graph_data: dict
# External definitions: { concept_name → plain-text definition }
# Sourced from Wikipedia or Tavily tool calls
external_defs: dict[str, str]
# graph_data with book definitions stripped / replaced by external_defs
# This is what gets forwarded to response_node
masked_data: dict