Add src/deep_agents_from_scratch/state.py

This commit is contained in:
2026-06-05 10:31:58 +00:00
parent 132fcbda68
commit a02f038557
+38
View File
@@ -0,0 +1,38 @@
"""State definition for the Deep Agent.
This module defines a lightweight dataclass that will be used as the
state for the :class:`StateGraph`. The state keeps the conversation
history, a virtual file system, and intermediate values produced by
the graph nodes.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Dict, List, Any
from langchain_core.messages import BaseMessage
@dataclass
class DeepAgentState:
"""State used by the StateGraph.
Attributes
----------
messages: List[BaseMessage]
The conversation messages.
files: Dict[str, str]
Virtual file system: mapping filename -> content.
query: str | None
Current search query.
search_results: List[Dict[str, Any]]
Raw search results from Tavily.
summaries: List[str]
Summaries of each search result.
"""
messages: List[BaseMessage] = field(default_factory=list)
files: Dict[str, str] = field(default_factory=dict)
query: str | None = None
search_results: List[Dict[str, Any]] = field(default_factory=list)
summaries: List[str] = field(default_factory=list)