-
Notifications
You must be signed in to change notification settings - Fork 9
improve TrajectorySummarizer: add type hints, detailed prompt templat…improve TrajectorySummarizer: type hints, paper §3.3 prompt template, and robust fallback #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,53 +1,127 @@ | ||||||||
| """ | ||||||||
| TrajectorySummarizer:HiAgent 论文 §3.3 (Observation Summarization) 模块的最小可用复刻。 | ||||||||
|
|
||||||||
| 背景:HiAgent 官方仓库 (HiAgent2024/HiAgent) 的 agentboard/agents/ 目录下缺失 summarize.py, | ||||||||
| issue #3 与 #4 均反映该模块缺失但作者尚未修复。本文件依据论文 §3.3 给出的 prompt 模板 | ||||||||
| 以及 cme_final.py 中对 TrajectorySummarizer 的调用(cme_final.py:160-182)复刻。 | ||||||||
|
|
||||||||
| 调用(来源:cme_final.py): | ||||||||
| summarizer = TrajectorySummarizer(self.llm_model) | ||||||||
| summary = summarizer.generate_summary([trajectory], [subgoal])[0] | ||||||||
|
|
||||||||
| 其中: | ||||||||
| - trajectory 是双重列表:List[List[(role, content)]],每个内层 list 通常是 | ||||||||
| [('Action', ...), ('Observation', ...)],调用前已剔除 "check valid actions" 项。 | ||||||||
| - subgoal 是 ('Subgoal', '<子目标文本>') 形式的元组。 | ||||||||
| - 返回值是与输入等长的字符串列表,每个元素是该 (trajectory, subgoal) 的浓缩摘要, | ||||||||
| 会被填入 cme_final.py 中作为压缩后的 Observation。 | ||||||||
|
|
||||||||
| LLM 接口签名(来源:agentboard/llm/openai_gpt.py:74 等): | ||||||||
| llm_model.generate(system_message: str, prompt: str) -> Tuple[bool, str] | ||||||||
|
||||||||
| llm_model.generate(system_message: str, prompt: str) -> Tuple[bool, str] | |
| llm_model.generate(system_message: str, prompt: str) -> Tuple[bool, Optional[str]] | |
| 其中失败时 completion 可能为 None。 |
Copilot
AI
Apr 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当前实现移除了空 trajectory 的显式处理;当 trajectory 为空或不包含 Observation 时,_last_observation() 会返回空字符串,最终会把空 Observation 写回历史(cme_final.py 会 new_history.append(..., ("Observation", summary)))。建议在 generate_summary 中对空/无 Observation 的情况返回一个非空占位文本(例如沿用旧实现的 "Subgoal completed."),避免下游出现空 observation。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
模块注释里引用的 cme_final.py 行号(“cme_final.py:160-182”)与当前仓库实际位置不一致,容易误导后续维护者。建议改为当前准确行号范围,或改成用函数名/搜索关键词引用而不是固定行号。