"""LangGraph 脚手架冒烟脚本(作业 1)。 同一 thread 输入两次、另一个 thread 输入一次,打印轮数和文本。 预期输出轮数依次为 1、2、1。 本脚本不导入 FastGPT、不读取其密钥;离线即可运行: python examples/langgraph_smoke.py """ import asyncio from src.agent.graph import build_graph async def main() -> None: graph = build_graph() async def ask(thread_id: str, text: str) -> None: # 只传本轮变化的字段;会话字段(turn_count 等)由 checkpoint 保管。 # 注意:对已有 checkpoint 的 thread 传入完整初始状态, # 其中的 turn_count=0 会覆盖已累计的值。 result = await graph.ainvoke( {"session_id": thread_id, "input_text": text}, config={"configurable": {"thread_id": thread_id}}, ) print( f"thread={thread_id} turn_count={result['turn_count']} " f"stage_code={result['stage_code']} text={result['response_text']}" ) await ask("thread-a", "你好") await ask("thread-a", "发生了交通事故") await ask("thread-b", "你好") if __name__ == "__main__": asyncio.run(main())