Repository navigation
fix: 修正第 8 章情景记忆示例未使用 query 参数的问题 - #170
Merged
webup merged 2 commits intoOct 27, 2026
Merged
Conversation
Collaborator
|
感谢 @ryukirin 发现问题并提供修正!让 合并前请再完善
补充覆盖这两个场景即可,保持示例简洁,无需扩展成复杂的检索实现。再次感谢你的贡献! |
Contributor
Author
|
非常感谢 @webup 的修改建议!
验证:
|
Collaborator
|
感谢 @ryukirin 的补充和细致修正!检索片段和消息正文的处理都已完善,复评通过,准备合并。感谢你的贡献! |
2 tasks done
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.
#169
问题
第八章的「情景记忆」中的
search_past_conversations(query, runtime)没有使用query,只按user_id取 5 个线程,再用get_history()返回检查点列表。官方文档 Memory 页面的示例也是这样写的。「后台记忆整合」中的search_recent_conversations同样声明了query,但没有使用。修改
search_past_conversations加了一个关键词匹配的实现,不知道合适不合适,希望能给一些意见search_past_conversations:先检查关键词,为空时返回提示,让模型带上关键词重新调用。仍取 5 个线程,并显式按更新时间倒序排列(接口文档没有规定默认顺序)。用get_state()读取当前消息,按关键词做字面匹配,跳过当前线程,最多返回 10 条、每条截取 300 个字符。工具说明里提示模型找不到时换用其他关键词。代码后补充一段说明。search_recent_conversations:去掉没有使用的query参数验证
在同一环境下运行修改后的两个代码块(
<DEPLOYMENT_URL>替换为本地地址,langchain 1.4.3)。换成较新的 langgraph-api 0.16.7,问题复现和修改后的结果都相同。工具函数用模拟的ToolRuntime(context.user_id和config中的thread_id)直接调用,没有经过模型:另外在
create_deep_agent的真实运行中确认,工具内的runtime.config["configurable"]["thread_id"]是当前线程编号。npm run build完成(21 page(s) built,Complete!)。