File size: 2,305 Bytes
7a0e3de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import sys, logging
sys.path.insert(0, ".")
logging.basicConfig(level=logging.WARNING)

from src.state import ResearchState
from src.agents.planner import planner_node
from src.agents.retriever import retriever_node
from src.agents.critic import critic_node
from src.agents.synthesizer import synthesizer_node
from src.memory import init_db, load_session

init_db()
print("=== Phase 7: Synthesizer Agent ===\n")

state: ResearchState = {
    "original_query": "What is the current state of speculative decoding in LLMs?",
    "session_id": "test-session-007",
    "session_context": None,
    "sub_questions": [],
    "retrieved_papers": [],
    "citation_graph": {},
    "web_results": [],
    "critic_verdict": "",
    "critic_notes": "",
    "rewritten_questions": [],
    "retry_count": 0,
    "synthesized_position": "",
    "claim_confidences": [],
    "session_update": None,
    "export_md": "",
    "decay_config": "linear",
    "calibration_bin": "",
    "latency_ms": 0.0,
}

print("Step 1: Planner...")
state = planner_node(state)
print(f"  {len(state['sub_questions'])} sub-questions generated")

print("Step 2: Retriever...")
state = retriever_node(state)
print(f"  {len(state['retrieved_papers'])} papers retrieved")

print("Step 3: Critic...")
state = critic_node(state)
print(f"  Verdict: {state['critic_verdict']}")

print("Step 4: Synthesizer (takes ~15s)...")
state = synthesizer_node(state)

print(f"\n--- Synthesizer Results ---")
print(f"  Position length: {len(state['synthesized_position'])} chars")
print(f"  Claims extracted: {len(state['claim_confidences'])}")
print(f"  Export MD length: {len(state['export_md'])} chars")

print(f"\n--- Position preview (first 500 chars) ---")
print(state['synthesized_position'][:500])

print(f"\n--- Claims ---")
for c in state['claim_confidences']:
    flag = " ⚠️" if c.flagged else ""
    print(f"  [{c.confidence.upper()}] {c.text[:70]}{flag}")
    print(f"    Source: {c.source_title[:50]} ({c.source_year})")

print(f"\n--- Session check ---")
session_ctx = load_session("test-session-007")
print(f"  Prior positions in DB: {len(session_ctx.prior_positions)}")
print(f"  Prior queries in DB: {len(session_ctx.prior_queries)}")

print(f"\n--- Export MD preview ---")
print(state['export_md'][:300])

print("\n✅ Phase 7 complete")