fix(tools): _require_paper detached session 导致 skim/deep_read/embed 报错 - #59
Merged
Merged
Conversation
根因:_require_paper 在 `with session_scope() as session:` 里 `return paper`, session 关闭后 paper 变 detached。read.py 的 _skim_paper/_deep_read_paper/ _embed_paper 在 session 外访问 paper.title/paper.abstract/paper.embedding, 触发 lazy load → 报 "Instance <Paper> is not bound to a Session"。 实测复现:confirm resume 执行 skim_paper 时 action_result success=false, summary 为 detached session 错误。LLM 看到失败后只能靠嘴总结,agent 可用性严重受损(看似 LLM 跑偏,实为工具层 bug)。 修复:在 session 关闭前: 1. 主动触发所有常用列属性加载(id/title/arxiv_id/abstract/pdf_path/ publication_date/embedding/read_status/metadata_json/favorited/rejected/ source/source_id/doi),防止 expunge 后访问未加载列报错 2. session.expunge(paper) 让 paper 带着已加载的属性离开 session Paper 无 relationship/lazy 字段,全是普通列,expunge 后访问安全。 影响范围:_skim_paper、_deep_read_paper、_embed_paper(均经 _require_paper)。 _figures_analysis、_reasoning_analysis 自己管理 session 且在 session 内 取属性,不受影响。 实测验证:fix 后 confirm resume skim_paper → action_result success=true, 返回完整粗读报告(one_liner/innovations/keywords/title_zh/abstract_zh), LLM 据此给出正确总结。
🔍 OpenCode PR Review Required这是一个受保护的分支,merge 前需要进行 code review。 请运行以下命令进行 OpenCode review: 或者在 PR 页面评论 This is an automated reminder from PR Review Gate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Critical 工具层 bug
现象:skim_paper / deep_read_paper / embed_paper 执行报错
Instance <Paper> is not bound to a Session,agent confirm resume 时 action_result success=false,LLM 只能靠嘴总结,可用性严重受损。根因:
_require_paper在with session_scope() as session:里return paper,session 关闭后 paper 变 detached。read.py 的 handler 在 session 外访问paper.title/paper.abstract/paper.embedding,触发 lazy load → 报错。修复:session 关闭前主动触发所有常用列属性加载 +
session.expunge(paper)。Paper 无 relationship/lazy 字段,expunge 后访问安全。实测验证:fix 后 confirm resume skim_paper →
action_result success=true,返回完整粗读报告(one_liner/innovations/keywords/title_zh/abstract_zh),LLM 据此给出正确总结。影响:v1
/agent/chat和 v2/agent/v2/chat均受影响(共用工具层)。此为生产 bug,需合 main。测试:81 passed / 2 skipped(无回归)。