Add on_request_start() / on_request_end() hooks to Chat
维护者通常 1 天内回复
@AbarnaaSree 已经在做这个了。
开始于 2026年9月9日。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 chatlas/_chat.py 开始,阅读 on_tool_request()、on_tool_result()、它们的 callback 存储方式,以及 chat() 和 chat_async() 路径。将提议的生命周期与 tidyverse/ellmer#1052 进行比较,然后定义每次模型请求的开始和结束 callback 行为,包括工具循环和无工具的情况。完成的标准是两条路径都能一致地提供并调用这些 hook。
由索引模型根据 Issue 内容生成。
描述
Summary
ellmer recently added on_request_start() / on_request_end() hooks on Chat (tidyverse/ellmer#1052). These fire around each model request within the tool-calling loop (not just around individual tool calls), letting callers inspect or rewrite the conversation between tool rounds within a single chat()/chat_async() call — e.g. to compact turns as the context window fills up.
chatlas currently only exposes tool-level callbacks: Chat.on_tool_request() and Chat.on_tool_result() (see chatlas/_chat.py). There's no equivalent hook that fires before/after each model request in the tool loop.
Proposed behavior (mirroring ellmer)
on_request_start(callback): callback receives the list of turns about to be sent, fired at the top of each tool-loop iteration (before the request is dispatched). Return value (if any) could allow rewriting the turns, mirroring ellmer's design.on_request_end(callback): callback receives the resulting turn after each model request completes.- Should fire correctly in both sync (
chat()) and async (chat_async()) paths, and work whether or not a tool loop actually runs.
References
- ellmer PR: tidyverse/ellmer#1052
- chatlas tool-level callbacks for comparison:
chatlas/_chat.py(on_tool_request,on_tool_result,_on_tool_request_callbacks,_on_tool_result_callbacks)
- 主要语言
- Python
- 星标
- 179
- 派生
- 32
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 10
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
posit-dev/chatlas 的其他 Issue
-
A streaming text delta that repeats everything streamed so far is missing from the recorded turn可能已有人在做 @cpsievert 于 81 天前认领。 未关闭ai-triage:done Priority: Medium
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
ai-triage:needs-review documentation
难度 2/5 1-2 天 新手友好度 76/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
-
ai-triage:done Priority: Low
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
查看 posit-dev/chatlas 的全部 Issue
相似的 Issue
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
country:US rating:6 request-theme type:TV SHOW
难度 1/5 1 小时以内 新手友好度 65/100
LizardByte/ThemerrDB#10501 · 1 条评论 ·
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 77/100
agentscope-ai/agentscope#4563 ·
维护者通常 2 天内回复
-
comp/desktop desktop/chat P3 type/bug
难度 2/5 1-3 小时 新手友好度 77/100
NousResearch/hermes-agent#164451 ·
维护者通常 1 天内回复
-
external integration integration-submission
难度 2/5 1-3 小时 新手友好度 68/100
langchain-ai/docs#8426 ·
维护者通常 1 天内回复