Add on_request_start() / on_request_end() hooks to Chat

オープン
#413 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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 の動作を定義します。両方のパスで一貫してフックを公開し、呼び出せれば完了です。

索引モデルが issue の本文から書いたものです。

説明

ai-triage:done Priority: Low

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時間
マージ済み PR(30日)
10

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

posit-dev/chatlas のほかの issue

posit-dev/chatlas の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。