@@ -77,14 +77,32 @@ def _apply_artifact_to_state_minimally(state: dict, node_id: str, artifact_text:
7777 parsed = _yaml .safe_load (artifact_text ) or {}
7878 if not isinstance (parsed , dict ):
7979 raise ValueError ("topic.yaml top-level must be a mapping" )
80- state ["topic" ] = parsed .get ("topic" , {}) or {}
81- state ["writer_brief" ] = parsed .get ("writer_brief" , {}) or {}
82- state ["handoff_to_researcher" ] = parsed .get ("handoff_to_researcher" , {}) or {}
80+ # v2 多话题
81+ topics_list = parsed .get ("topics" , [])
82+ if topics_list and isinstance (topics_list , list ):
83+ state ["scout_topics" ] = topics_list
84+ # 重新选中:保留当前 selected_topic_id,若已无效则选第一个
85+ sel_id = state .get ("selected_topic_id" , "" )
86+ valid_ids = [t .get ("topic_id" ) for t in topics_list ]
87+ if sel_id not in valid_ids :
88+ sel_id = valid_ids [0 ] if valid_ids else ""
89+ state ["selected_topic_id" ] = sel_id
90+ # 用选中的话题更新顶级字段
91+ chosen = next ((t for t in topics_list if t .get ("topic_id" ) == sel_id ), topics_list [0 ] if topics_list else {})
92+ state ["topic" ] = chosen
93+ state ["writer_brief" ] = chosen .get ("writer_brief" , {}) or {}
94+ state ["handoff_to_researcher" ] = chosen .get ("handoff_to_researcher" , {}) or {}
95+ else :
96+ # v1 兼容
97+ state ["topic" ] = parsed .get ("topic" , {}) or {}
98+ state ["writer_brief" ] = parsed .get ("writer_brief" , {}) or {}
99+ state ["handoff_to_researcher" ] = parsed .get ("handoff_to_researcher" , {}) or {}
83100 state ["reference_articles" ] = parsed .get ("reference_articles" , []) or []
84101 state ["user_requirements" ] = parsed .get ("user_requirements" , {}) or {}
85102 state ["reference_index" ] = parsed .get ("reference_index" , {}) or {}
86103 state ["link_usage_policy" ] = parsed .get ("link_usage_policy" , {}) or {}
87104 state ["scout_process_summary" ] = parsed .get ("scout_process_summary" , {}) or {}
105+ state ["search_execution_log" ] = parsed .get ("search_execution_log" , {}) or {}
88106 state ["current_stage" ] = "scout"
89107 return
90108
0 commit comments