fix(async-tasks): wake the parent conversation by id, not by source
Nightly Build / build (push) Successful in 2m28s
Nightly Build / build (push) Successful in 2m28s
DurableSink resumed the parent through ChatHub::resume(&source), which resolves whatever session the source currently points at. Since one source can now carry several conversations (secondary tabs, a reset since the task started), that pointer is no longer the conversation the result was delivered into: the recovery ran on the wrong one, found nothing pending, and returned silently — the delivered task_completed sat unread until the user's next message drove a normal turn. The sink already knows the parent session id, so resume it directly through resume_for_session, keeping the same in-flight guard. The source lookup and the now-unused pool field go with it. Adds a crate-level regression test: a completed turn, a StoreSink delivery, then a recovery — the result must drive a new round.
This commit is contained in:
@@ -379,6 +379,34 @@ async fn an_interrupted_parallel_batch_is_reaped_and_the_parent_resumes() {
|
||||
assert_eq!(report.frames_resumed, 1, "the root continues with the failures in view");
|
||||
}
|
||||
|
||||
// ── async result wake-up (reproduction) ──────────────────────────────────────
|
||||
|
||||
#[tokio::test]
|
||||
async fn an_idle_conversation_woken_by_an_async_result_continues() {
|
||||
use agent_loop::delegate::{AsyncResultSink, CompletedTask, StoreSink};
|
||||
use agent_loop::ids::TaskId;
|
||||
|
||||
let h = H::new(vec![Step::message("processing the task result")], vec![]).await;
|
||||
|
||||
// The parent's turn is complete: user message, final assistant reply.
|
||||
h.store.append(h.root, NewMessage::user("start a task")).await.unwrap();
|
||||
h.store.append(h.root, NewMessage::assistant("started, I'll let you know", None)).await.unwrap();
|
||||
|
||||
// The task finishes: the sink writes the synthetic delivery, then the host
|
||||
// wakes the conversation with a recovery.
|
||||
let sink = StoreSink::new(h.store.clone());
|
||||
sink.deliver(h.conv.clone(), CompletedTask {
|
||||
id: TaskId(7),
|
||||
title: "research".into(),
|
||||
result: "the answer is 42".into(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let report = h.recover().await;
|
||||
assert_eq!(report.frames_resumed, 1, "the delivered result must drive a new round");
|
||||
}
|
||||
|
||||
// ── resolve_pending ──────────────────────────────────────────────────────────
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user