Keep the handoff continuation message when its turn is folded away

This commit is contained in:
Ian Gulliver
2026-10-15 11:16:50 -07:00
parent d83212d46b
commit 3fe0374ac5
7 changed files with 25 additions and 5 deletions
+5
View File
@@ -3,6 +3,7 @@ package agents
import (
"context"
"log/slog"
"strings"
"g.fc.run/misc/byre/internal/api"
)
@@ -36,6 +37,10 @@ func isHandoffPrompt(actor, text string) bool {
return actor == "byre" && (text == handoffPrompt || text == leadHandoffPrompt)
}
func isContinuation(actor, text string) bool {
return actor == "byre" && (strings.HasPrefix(text, handoffPreamble) || strings.HasPrefix(text, leadHandoffPreamble))
}
func (m *Manager) continueFromHandoff(sessionID, handoff string) {
ctx := context.Background()
err := m.handoff(ctx, sessionID, handoff)
+3
View File
@@ -592,6 +592,9 @@ func (m *Manager) message(ctx context.Context, l *live, actor, text string, imag
if compacting {
payload["handoff"] = true
}
if isContinuation(actor, text) {
payload["continuation"] = true
}
err := m.emit(ctx, l, actor, "user.message", payload)
if err != nil {
return err
+7
View File
@@ -595,7 +595,11 @@ func TestCompactCarriesHandoff(t *testing.T) {
ev.AgentSessionId != nil && *ev.AgentSessionId != old.Id
})
continued := false
for _, ev := range events {
if ev.Kind == "user.message" && *ev.AgentSessionId != old.Id {
continued = ev.Payload["continuation"] == true
}
if ev.Kind == "turn.ended" && *ev.AgentSessionId == old.Id {
if ev.Payload["handoff"] != true || ev.Payload["inbox_item_id"] != nil {
t.Fatalf("handoff turn.ended %v: want handoff and no inbox summary", ev.Payload)
@@ -605,6 +609,9 @@ func TestCompactCarriesHandoff(t *testing.T) {
t.Fatalf("handoff prompt %v: want handoff flag", ev.Payload)
}
}
if !continued {
t.Fatalf("new session's first message lacks the continuation flag")
}
sessions, err := e.store.ListSessions(e.ctx, e.task.Id)
if err != nil {