07d4740d0c
Claude Code records subagent/peer reports, task notifications, reminders and skill bodies as user-role entries. Classify them server-side (history and live stream) by origin/isMeta/queued_command mode: reports become kind agent_report, task notifications kind notice, harness meta is hidden, and the mid-turn wrapper is unwrapped to the operator's text. The app draws a collapsed Agent report card and a one-line system notice on the agent's side.
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
)
|
|
|
|
// A live agent report keeps its kind and sender across a resume snapshot, and
|
|
// is never mistaken for the agent's final reply.
|
|
func TestHubKeepsInjectedMessageKind(t *testing.T) {
|
|
h := newChatHub()
|
|
h.apply(protocol.ChatEventFrame{SessionID: "s", MessageID: "msg_1", Kind: protocol.ChatEventText, Delta: "The answer", Part: &protocol.ChatPart{ID: "msg_1#text#0"}})
|
|
h.apply(protocol.ChatEventFrame{
|
|
SessionID: "s", MessageID: "agent-report-x", MessageKind: protocol.ChatMessageKindAgentReport, Kind: protocol.ChatEventText,
|
|
Delta: "## Report", Part: &protocol.ChatPart{ID: "agent-report-x#text#0", Name: "general-purpose"},
|
|
})
|
|
messages := h.snapshot("s")
|
|
if len(messages) != 2 || messages[0].Kind != "" || messages[1].Kind != protocol.ChatMessageKindAgentReport ||
|
|
messages[1].Role != protocol.ChatRoleAssistant || messages[1].Parts[0].Name != "general-purpose" || messages[1].Parts[0].Text != "## Report" {
|
|
t.Fatalf("snapshot: %+v", messages)
|
|
}
|
|
h.mu.Lock()
|
|
reply := h.finalReplyTextLocked("s")
|
|
h.mu.Unlock()
|
|
if reply != "The answer" {
|
|
t.Fatalf("final reply must skip the report, got %q", reply)
|
|
}
|
|
}
|