Add messages to a response while it runs (steering between tool rounds)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read the OpenAI provider's streaming and nonstreaming tool loops and the ToolExecutionDelegate definition; the issue cites a fork implementation at gtokman/AnyLanguageModel@8f2d9f8. Compare how each loop builds requests and transcript entries, then decide whether the library should support queued messages and what happens to messages still pending when a response ends. Done means a design is agreed on for the API shape, message types, and end-of-response semantics.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A long response with tools can run for a minute or more: search, read some pages, compare, write. While it runs, the person often wants to adjust it ("skip Delta", "under $300", "actually make it Lisbon"). Today an app's only option is to cancel the response and start a new one, which throws away the lookups already done.
What we wanted was to send messages into the running response: after a round of tool calls, before the model's next request, add what the person has sent since, and the model reads it alongside the tool results.
Why it's easy to get wrong. The added messages have to go into the request and the transcript, in the same form and in the same place (after the round's tool outputs). If the in-flight request and a later replay of the transcript differ, a prompt cache that matches on exact prefixes (Anthropic's, for example) misses on every later turn. That's the same problem #325 fixed for tool calls. An app can't do this from outside: it doesn't control what goes into the next request mid-loop.
What we did. Our fork adds one method to ToolExecutionDelegate (gtokman/AnyLanguageModel@8f2d9f8):
/// Asked after each round of tool calls, before the model's next request.
/// The messages are added to the transcript as prompts, in order,
/// after the round's tool outputs. The default adds nothing.
func pendingMessages(in session: LanguageModelSession) async -> [String]
The OpenAI provider asks for messages after each round, in both the streaming and nonstreaming loops. It appends each one as a .prompt entry and as the matching user message in the request, so replay sends them exactly as they were sent. Our server keeps a per-conversation inbox. A small model also answers the person right away ("Got it, I'll leave Delta out."), and the main model is told it already said that, so it doesn't acknowledge twice.
The shape is a question for you. A delegate method fit our server, but there are other designs:
- a method on the session to queue a message for the response in progress (
session.enqueue("skip Delta")), which is closer to how an app thinks about it; - tying it to dynamic instructions or profiles (#344–#348), since those already re-resolve the request each round;
- only
Strings, or fullPrompts (images, for example)?
And a semantics question: if the response ends with no further tool round, should messages still pending start a new turn, be returned to the caller, or be dropped? Our server interrupts the response if the model is writing its final text, and starts a new response from the messages (the lookups stay in the transcript; the unfinished text doesn't). Any that arrive as the reply closes go back to the app, which sends them as a normal message.
Does this belong in the library, and if so, which shape would you prefer? Happy to do the PR.
- Ngôn ngữ chính
- Swift
- Star
- 959
- Fork
- 99
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 59
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/AnyLanguageModel
-
Cancelling a collected stream throws noSnapshots instead of CancellationErrorCó thể đã có người làm @akbashev đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
huggingface/AnyLanguageModel#361 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Run a round's tool calls at onceĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
huggingface/AnyLanguageModel#359 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
huggingface/AnyLanguageModel#328 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
huggingface/AnyLanguageModel#327 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OpenAI Chat Completions: tool rounds drop the model's reasoningCó thể đã có người làm @gtokman đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
huggingface/AnyLanguageModel#326 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/AnyLanguageModel
Issue tương tự
-
a:false-positive
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Idle CPU stays at ~8% after the "Text wasn't inserted" card is shown onceCó thể đã có người làm @nickbecker đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
altic-dev/FluidVoice#1217 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BrainBar Watcher chart: unavailable-flow tooltip/accessibility drops the health reason for .attention/.stoppedCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
EtanHey/brainlayer#1439 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
alejandrobujan/tendedero#98 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
vorssaint/vorssaint-utils#3368 ·
Maintainer thường phản hồi trong vòng 1 ngày