-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_state.py
More file actions
56 lines (44 loc) Β· 2.86 KB
/
agent_state.py
File metadata and controls
56 lines (44 loc) Β· 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
AgentState β shared state schema for the LangGraph agent.
Consumed by all nodes in langgraph_agent.py:
RouterNode β ChiefArchitect β DeepScout β DataAnalyst
β LeadWriter β CriticMaster β Synthesizer
Part 1 fields are preserved unchanged for backward compatibility.
Part 2 fields are Optional with default None so existing code doesn't break.
"""
from typing import Literal, Optional, TypedDict # noqa: F401 β Optional used below
class AgentState(TypedDict):
# ββ Part 1 fields (unchanged) βββββββββββββββββββββββββββββββββββββββββββββ
question: str
intent: Literal["policy_query", "market_analysis", "data_query", "research", "general"]
plan: list[dict] # steps from PlannerNode (legacy)
steps_executed: list[dict] # plan steps enriched with "result" key
reflection: str # raw JSON string from ReflectorNode LLM call
confidence: float # 0.0β1.0 extracted from reflection
final_answer: str
iteration: int # increments on each planner call; capped at MAX_ITER
session_id: str
# ββ Part 2 fields βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Planning layer
outline: list[dict] # [{id, title, description, query}]
hypotheses: list[str] # verifiable research hypotheses
research_questions: list[str] # decomposed sub-questions
# Knowledge layer
facts: list[dict] # [{content, source, credibility}]
raw_sources: list[dict] # raw source objects from search/RAG
data_points: list[dict] # structured numeric data points
# Output layer
draft_sections: dict # {section_id: content}
charts_data: list[dict] # chart configs / base64 images
references: list[dict] # [{title, url, date}]
# Review layer
critic_issues: list[dict] # [{type, severity, section, description}]
pending_queries: list[str] # queries to re-research
quality_score: float # 0.0β1.0
# Flow control
phase: str # planning/researching/analyzing/writing/reviewing/awaiting_human/done
demo_mode: bool # True = limit scope (2 questions, 2 sections, skip re-research)
# Human-in-the-loop (OPT-003)
user_decision: Optional[str] # "approve" | "reject" | None (not yet decided)
awaiting_human: bool # True while human_gate_node is polling for decision
issue_summary: str # rendered issue list pushed to SSE for UI display