The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(factory): never report a hidden transcript message as the reply
Claude5c3ba4039b26
diff --git a/cli/beacon-hooks/cmd/factory_reply.go b/cli/beacon-hooks/cmd/factory_reply.goindex d2971397..260afa79 100644--- a/cli/beacon-hooks/cmd/factory_reply.go+++ b/cli/beacon-hooks/cmd/factory_reply.go@@ -53,8 +53,9 @@ func factoryTranscriptReply(path string) (factoryReply, bool) {Type string `json:"type"`ID string `json:"id"`Message *struct {- Role string `json:"role"`- Content json.RawMessage `json:"content"`+ Role string `json:"role"`+ Visibility string `json:"visibility"`+ Content json.RawMessage `json:"content"`} `json:"message"`}if json.Unmarshal(line, &record) != nil {@@ -67,6 +68,13 @@ func factoryTranscriptReply(path string) (factoryReply, bool) {if record.Message.Role != "assistant" {return factoryReply{}, false}+ // A message hidden from one side of the conversation is not the reply: the session sync+ // drops user_only messages and records llm_only ones as errors, and the live path must not+ // call either the turn's answer. Refused rather than skipped, so an earlier message is not+ // promoted in its place.+ if v := record.Message.Visibility; v == "user_only" || v == "llm_only" {+ return factoryReply{}, false+ }text, hasToolUse := factoryAssistantText(record.Message.Content)if hasToolUse || strings.TrimSpace(text) == "" {return factoryReply{}, falsediff --git a/cli/beacon-hooks/cmd/factory_reply_test.go b/cli/beacon-hooks/cmd/factory_reply_test.goindex e904246f..5ae0d952 100644--- a/cli/beacon-hooks/cmd/factory_reply_test.go+++ b/cli/beacon-hooks/cmd/factory_reply_test.go@@ -104,6 +104,33 @@ func TestFactoryTranscriptReplyRefusesAnUnfinishedTurn(t *testing.T) {}}+// A message hidden from the user or from the model is never the reply, matching the session sync,+// which drops user_only messages and records llm_only ones as errors. It is refused, not skipped,+// so the visible message before it is not reported in its place.+func TestFactoryTranscriptReplyRefusesHiddenMessages(t *testing.T) {+ for _, visibility := range []string{"user_only", "llm_only"} {+ t.Run(visibility, func(t *testing.T) {+ path := filepath.Join(t.TempDir(), "s.jsonl")+ hidden, err := json.Marshal(map[string]interface{}{+ "type": "message",+ "id": "hidden",+ "message": map[string]interface{}{+ "role": "assistant",+ "visibility": visibility,+ "content": []interface{}{factoryText("internal notice")},+ },+ })+ if err != nil {+ t.Fatal(err)+ }+ writeTranscript(t, path, append(factoryTurn("t1", "visible answer"), string(hidden))...)+ if reply, ok := factoryTranscriptReply(path); ok {+ t.Fatalf("reported %#v; a %s message is not the reply", reply, visibility)+ }+ })+ }+}+// A record still being written is skipped, and the newest complete record decides.func TestFactoryTranscriptReplySkipsAPartialLastLine(t *testing.T) {path := filepath.Join(t.TempDir(), "s.jsonl")