Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix prompt events

Justin D'Souza3c7fb87f36fe
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index 0ee64077..045aeefd 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -257,12 +257,13 @@ func init() {
endpointInstallCmd.Flags().IntVar(&endpointOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")
endpointInstallCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the launchd service")
- endpointInstallCmd.Flags().StringVar(&endpointOpts.contentRetention, "content-retention", "metadata", "Content retention mode: metadata, redacted, or full")
+ endpointInstallCmd.Flags().StringVar(&endpointOpts.contentRetention, "content-retention", "full", "Content retention mode: metadata, redacted, or full")
endpointRepairCmd.Flags().StringVar(&endpointOpts.harnesses, "harness", "claude,codex", "Comma-separated harnesses to configure")
endpointRepairCmd.Flags().IntVar(&endpointOpts.grpcPort, "otlp-grpc-port", endpointconfig.DefaultGRPCPort, "Local OTLP gRPC port")
endpointRepairCmd.Flags().IntVar(&endpointOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")
endpointRepairCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
- endpointRepairCmd.Flags().StringVar(&endpointOpts.contentRetention, "content-retention", "metadata", "Content retention mode: metadata, redacted, or full")
+ endpointRepairCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the launchd service")
+ endpointRepairCmd.Flags().StringVar(&endpointOpts.contentRetention, "content-retention", "full", "Content retention mode: metadata, redacted, or full")
endpointDashboardCmd.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
endpointDashboardCmd.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
endpointDashboardCmd.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.go
index 13cd9a7d..8cd8b942 100644
--- a/cli/beacon/cmd/endpoint_test.go
+++ b/cli/beacon/cmd/endpoint_test.go
@@ -92,6 +92,12 @@ func TestEndpointHarnessDefaultsDoNotClobberInstall(t *testing.T) {
}
}
+func TestEndpointRepairSupportsNoStart(t *testing.T) {
+ if endpointRepairCmd.Flags().Lookup("no-start") == nil {
+ t.Fatal("repair command missing --no-start flag")
+ }
+}
+
func TestEndpointCommandsDefaultToUserMode(t *testing.T) {
for _, cmd := range []*cobra.Command{endpointInstallCmd, endpointStatusCmd, endpointDashboardCmd, endpointHooksInstallCmd} {
userFlag := cmd.Flags().Lookup("user")
diff --git a/cli/beacon/internal/embedded/hooks.bin b/cli/beacon/internal/embedded/hooks.bin
old mode 100755
new mode 100644
diff --git a/cli/beacon/internal/endpoint/config/config.go b/cli/beacon/internal/endpoint/config/config.go
index eb2f8f59..335e4ad5 100644
--- a/cli/beacon/internal/endpoint/config/config.go
+++ b/cli/beacon/internal/endpoint/config/config.go
@@ -45,7 +45,7 @@ func Default(userMode bool, logPath string) Config {
UserMode: userMode,
LogPath: logPath,
Harnesses: []string{"claude", "codex"},
- ContentRetention: ContentRetentionMetadata,
+ ContentRetention: ContentRetentionFull,
Collector: Collector{
ConfigPath: filepath.Join(base, "otelcol.yaml"),
GRPCPort: DefaultGRPCPort,
@@ -88,7 +88,7 @@ func Load(userMode bool) (Config, error) {
return Config{}, err
}
if cfg.ContentRetention == "" {
- cfg.ContentRetention = ContentRetentionMetadata
+ cfg.ContentRetention = ContentRetentionFull
}
if err := ValidateContentRetention(cfg.ContentRetention); err != nil {
return Config{}, err
@@ -98,7 +98,7 @@ func Load(userMode bool) (Config, error) {
func Save(cfg Config) (string, error) {
if cfg.ContentRetention == "" {
- cfg.ContentRetention = ContentRetentionMetadata
+ cfg.ContentRetention = ContentRetentionFull
}
if err := ValidateContentRetention(cfg.ContentRetention); err != nil {
return "", err
diff --git a/cli/beacon/internal/endpoint/config/config_test.go b/cli/beacon/internal/endpoint/config/config_test.go
index a8123768..38e8dfe4 100644
--- a/cli/beacon/internal/endpoint/config/config_test.go
+++ b/cli/beacon/internal/endpoint/config/config_test.go
@@ -27,8 +27,8 @@ func TestDefaultUserConfigUsesHomeScopedPaths(t *testing.T) {
if len(cfg.Harnesses) != 2 || cfg.Harnesses[0] != "claude" || cfg.Harnesses[1] != "codex" {
t.Fatalf("unexpected default harnesses: %#v", cfg.Harnesses)
}
- if cfg.ContentRetention != ContentRetentionMetadata {
- t.Fatalf("ContentRetention = %q, want %q", cfg.ContentRetention, ContentRetentionMetadata)
+ if cfg.ContentRetention != ContentRetentionFull {
+ t.Fatalf("ContentRetention = %q, want %q", cfg.ContentRetention, ContentRetentionFull)
}
}
@@ -68,6 +68,26 @@ func TestSaveLoadRoundTrip(t *testing.T) {
}
}
+func TestLoadDefaultsMissingContentRetentionToFull(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+ path := filepath.Join(home, UserConfigPath)
+ if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
+ t.Fatalf("mkdir config dir: %v", err)
+ }
+ if err := os.WriteFile(path, []byte(`{"user_mode":true}`), 0644); err != nil {
+ t.Fatalf("write config: %v", err)
+ }
+
+ loaded, err := Load(true)
+ if err != nil {
+ t.Fatalf("Load returned error: %v", err)
+ }
+ if loaded.ContentRetention != ContentRetentionFull {
+ t.Fatalf("ContentRetention = %q, want %q", loaded.ContentRetention, ContentRetentionFull)
+ }
+}
+
func TestLoadRejectsCorruptJSON(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
diff --git a/cli/beacon/internal/endpoint/dashboard/events.go b/cli/beacon/internal/endpoint/dashboard/events.go
index a8d9d5c6..d303080e 100644
--- a/cli/beacon/internal/endpoint/dashboard/events.go
+++ b/cli/beacon/internal/endpoint/dashboard/events.go
@@ -350,6 +350,9 @@ func searchFields(record EventRecord) []string {
if event.Policy != nil {
fields = append(fields, event.Policy.ID, event.Policy.Name, event.Policy.Decision, event.Policy.Enforcement, event.Policy.Reason)
}
+ if event.Prompt != nil {
+ fields = append(fields, event.Prompt.Text)
+ }
if event.Content != nil {
fields = append(fields, event.Content.Retention)
if event.Content.Included {
diff --git a/cli/beacon/internal/endpoint/dashboard/events_test.go b/cli/beacon/internal/endpoint/dashboard/events_test.go
index aa7e5eca..80cbe59f 100644
--- a/cli/beacon/internal/endpoint/dashboard/events_test.go
+++ b/cli/beacon/internal/endpoint/dashboard/events_test.go
@@ -112,6 +112,7 @@ func TestReadEventsFreeTextSearchMatchesStructuredFields(t *testing.T) {
testSchemaEvent("2026-05-13T01:01:00Z", "cursor", "file.modified", "file", "repo-b"),
testSchemaEvent("2026-05-13T01:02:00Z", "cursor", "mcp.tool_invoked", "mcp", "repo-c"),
testSchemaEvent("2026-05-13T01:03:00Z", "cursor", "approval.denied", "approval", "repo-d"),
+ testSchemaEvent("2026-05-13T01:04:00Z", "cursor", "prompt.submitted", "prompt", "repo-e"),
}
events[0].Command = &schema.CommandInfo{Command: "go test ./internal/endpoint/dashboard"}
events[0].Session = &schema.SessionInfo{ID: "session-command"}
@@ -119,9 +120,10 @@ func TestReadEventsFreeTextSearchMatchesStructuredFields(t *testing.T) {
events[2].MCP = &schema.MCPInfo{Server: "github", Tool: "get_issue"}
events[3].Approval = &schema.ApprovalInfo{Decision: "denied", Reason: "dangerous shell"}
events[3].Message = "approval blocked for review"
+ events[4].Prompt = &schema.PromptInfo{Text: "summarize local telemetry"}
writeTestLog(t, path, marshalEvents(t, events...)...)
- for _, query := range []string{"dashboard", "cmd/server.go", "github get_issue", "dangerous shell", "session-command", "repo-c", "blocked review"} {
+ for _, query := range []string{"dashboard", "cmd/server.go", "github get_issue", "dangerous shell", "session-command", "repo-c", "blocked review", "summarize telemetry"} {
result, err := ReadEvents(path, EventQuery{Q: query, Limit: 10})
if err != nil {
t.Fatalf("ReadEvents(%q) returned error: %v", query, err)
diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.js
index d7793eeb..20738fdc 100644
--- a/cli/beacon/internal/endpoint/dashboard/static/app.js
+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js
@@ -265,12 +265,14 @@ function signalCell(record) {
}
function primaryArtifact(event) {
+ if (event.prompt?.text) return event.prompt.text;
if (event.command?.command) return event.command.command;
if (event.file?.path) return `${event.file.operation || "file"} ${event.file.path}`;
if (event.mcp?.server || event.mcp?.tool) return [event.mcp.server, event.mcp.tool].filter(Boolean).join(" / ");
if (event.tool?.name || event.tool?.command) return [event.tool.name, event.tool.command].filter(Boolean).join(" ");
if (event.approval?.decision || event.approval?.reason) return [event.approval.decision, event.approval.reason].filter(Boolean).join(": ");
if (event.policy?.decision || event.policy?.name) return [event.policy.decision, event.policy.name].filter(Boolean).join(": ");
+ if (event.raw?.metric_name) return event.raw.metric_name;
return event.model || event.branch || "";
}
@@ -297,7 +299,8 @@ function detailSummary(record) {
["Wazuh level", record.wazuh_level || ""],
["Session", event.session?.id],
["Repository", repositoryLabel(event)],
- ["Artifact", primaryArtifact(event)],
+ ["Prompt", event.prompt?.text],
+ ["Artifact", event.prompt?.text ? "" : primaryArtifact(event)],
["Approval", event.approval ? [event.approval.decision, event.approval.reason].filter(Boolean).join(": ") : ""],
["Policy", event.policy ? [event.policy.decision, event.policy.name, event.policy.reason].filter(Boolean).join(": ") : ""],
["Content", event.content ? `${event.content.retention}${event.content.redacted ? ", redacted" : ""}${event.content.truncated ? ", truncated" : ""}` : ""],
diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.go
index ceb743e6..12239c1f 100644
--- a/cli/beacon/internal/endpoint/harness/harness.go
+++ b/cli/beacon/internal/endpoint/harness/harness.go
@@ -32,8 +32,9 @@ type Harness struct {
}
type ConfigureOptions struct {
- Endpoint string
- UserMode bool
+ Endpoint string
+ UserMode bool
+ ContentRetention string
}
type ValidationResult struct {
@@ -190,7 +191,7 @@ func ConfigureCodex(opts ConfigureOptions) (string, error) {
return "", err
}
}
- updated := mergeCodexOTEL(existing, opts.Endpoint)
+ updated := mergeCodexOTELWithPrompt(existing, opts.Endpoint, opts.ContentRetention != "metadata")
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return "", err
}
@@ -215,6 +216,10 @@ func ValidateConfigured(endpoint string) []ValidationResult {
}
func mergeCodexOTEL(existing, endpoint string) string {
+ return mergeCodexOTELWithPrompt(existing, endpoint, true)
+}
+
+func mergeCodexOTELWithPrompt(existing, endpoint string, logUserPrompt bool) string {
lines := strings.Split(existing, "\n")
var out []string
inOTEL := false
@@ -224,7 +229,7 @@ func mergeCodexOTEL(existing, endpoint string) string {
if strings.HasPrefix(trim, "[") && strings.HasSuffix(trim, "]") {
isOTELHeader := codexOTELHeader(trim)
if inOTEL && !isOTELHeader && !wroteOTEL {
- out = append(out, codexOTELBlock(endpoint)...)
+ out = append(out, codexOTELBlock(endpoint, logUserPrompt)...)
wroteOTEL = true
}
inOTEL = isOTELHeader
@@ -239,14 +244,14 @@ func mergeCodexOTEL(existing, endpoint string) string {
out = append(out, line)
}
if inOTEL && !wroteOTEL {
- out = append(out, codexOTELBlock(endpoint)...)
+ out = append(out, codexOTELBlock(endpoint, logUserPrompt)...)
wroteOTEL = true
}
if !wroteOTEL {
if strings.TrimSpace(existing) != "" {
out = append(out, "")
}
- out = append(out, codexOTELBlock(endpoint)...)
+ out = append(out, codexOTELBlock(endpoint, logUserPrompt)...)
}
return strings.TrimRight(strings.Join(out, "\n"), "\n") + "\n"
}
@@ -255,11 +260,11 @@ func codexOTELHeader(header string) bool {
return header == "[otel]" || strings.HasPrefix(header, "[otel.")
}
-func codexOTELBlock(endpoint string) []string {
+func codexOTELBlock(endpoint string, logUserPrompt bool) []string {
return []string{
"[otel]",
"environment = \"dev\"",
- "log_user_prompt = false",
+ fmt.Sprintf("log_user_prompt = %t", logUserPrompt),
"",
"[otel.exporter.\"otlp-grpc\"]",
fmt.Sprintf("endpoint = %q", endpoint),
diff --git a/cli/beacon/internal/endpoint/harness/harness_test.go b/cli/beacon/internal/endpoint/harness/harness_test.go
index 730a3903..f0126f13 100644
--- a/cli/beacon/internal/endpoint/harness/harness_test.go
+++ b/cli/beacon/internal/endpoint/harness/harness_test.go
@@ -137,7 +137,7 @@ func TestConfigureCodexWritesTelemetryBlockAndBackup(t *testing.T) {
"model = \"gpt-5\"",
"[otel]",
"environment = \"dev\"",
- "log_user_prompt = false",
+ "log_user_prompt = true",
"[otel.exporter.\"otlp-grpc\"]",
"[otel.trace_exporter.\"otlp-grpc\"]",
"[otel.metrics_exporter.\"otlp-grpc\"]",
@@ -156,6 +156,27 @@ func TestConfigureCodexWritesTelemetryBlockAndBackup(t *testing.T) {
}
}
+func TestConfigureCodexDisablesPromptLoggingForMetadataRetention(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+
+ path, err := ConfigureCodex(ConfigureOptions{
+ Endpoint: "http://127.0.0.1:4317",
+ UserMode: true,
+ ContentRetention: "metadata",
+ })
+ if err != nil {
+ t.Fatalf("ConfigureCodex returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read codex config: %v", err)
+ }
+ if !strings.Contains(string(data), "log_user_prompt = false") {
+ t.Fatalf("metadata retention should disable Codex prompt logging:\n%s", string(data))
+ }
+}
+
func TestDiscoverCodexDoesNotDetectConfigDirectoryOnly(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
diff --git a/cli/beacon/internal/endpoint/integrations/cowork/cowork.go b/cli/beacon/internal/endpoint/integrations/cowork/cowork.go
index 48f9848c..835864ce 100644
--- a/cli/beacon/internal/endpoint/integrations/cowork/cowork.go
+++ b/cli/beacon/internal/endpoint/integrations/cowork/cowork.go
@@ -74,7 +74,7 @@ Notes:
- Claude Cowork export is configured by a Team/Enterprise admin.
- Claude Desktop must be version %s or newer.
- The OTLP endpoint must be reachable by Claude Cowork. Use a public HTTPS collector or an authenticated tunnel for local testing.
-- Cowork may include prompt text and tool parameters. Beacon's collector should redact/drop content by default before writing Wazuh JSONL.
+- Cowork may include prompt text and tool parameters. Beacon's collector writes configured content fields by default; choose metadata or redacted retention for stricter deployments.
`, AdminURL, cfg.Endpoint, cfg.Protocol, headerText(cfg.Headers), resourceAttributesText(cfg.ResourceAttributes), MinVersion)
}
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
index c4ee772e..66dbd3a1 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
@@ -237,6 +237,8 @@ func ResolveRuntimeLog(userMode bool, logPath string) RuntimeLogSource {
func selectRuntimeLog(source RuntimeLogSource, requestedService, systemService service.Status, systemCfg endpointconfig.Config) RuntimeLogSource {
if systemService.Running && !requestedService.Running {
source.Reason = "requested endpoint configuration; system collector is also running on the configured OTLP ports"
+ source.EffectiveUserMode = false
+ source.EffectiveLogPath = systemCfg.LogPath
source.Warning = fmt.Sprintf("system collector is writing OTLP events to %s instead of the user runtime log %s; stop the system collector or install user mode to keep all events in one file", systemCfg.LogPath, source.RequestedLogPath)
}
return source
@@ -315,7 +317,7 @@ func configureHarnesses(cfg endpointconfig.Config) ([]string, error) {
}
paths = append(paths, path)
case "codex", "codex_cli":
- path, err := harness.ConfigureCodex(harness.ConfigureOptions{Endpoint: endpoint, UserMode: cfg.UserMode})
+ path, err := harness.ConfigureCodex(harness.ConfigureOptions{Endpoint: endpoint, UserMode: cfg.UserMode, ContentRetention: string(cfg.ContentRetention)})
if err != nil {
return paths, err
}
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
index 500830a1..8d81d859 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
@@ -75,11 +75,11 @@ func TestSelectRuntimeLogWarnsWhenSystemCollectorConflictsWithUserMode(t *testin
systemCfg,
)
- if !got.EffectiveUserMode {
- t.Fatal("expected effective user mode")
+ if got.EffectiveUserMode {
+ t.Fatal("expected effective system mode")
}
- if got.EffectiveLogPath != userLog {
- t.Fatalf("EffectiveLogPath = %q, want %q", got.EffectiveLogPath, userLog)
+ if got.EffectiveLogPath != systemLog {
+ t.Fatalf("EffectiveLogPath = %q, want %q", got.EffectiveLogPath, systemLog)
}
if got.Warning == "" || !strings.Contains(got.Warning, userLog) || !strings.Contains(got.Warning, systemLog) {
t.Fatalf("Warning = %q, want user/system log paths", got.Warning)
diff --git a/cli/beacon/internal/endpoint/schema/event.go b/cli/beacon/internal/endpoint/schema/event.go
index 95294588..d50dc72f 100644
--- a/cli/beacon/internal/endpoint/schema/event.go
+++ b/cli/beacon/internal/endpoint/schema/event.go
@@ -91,6 +91,10 @@ type PolicyInfo struct {
Reason string `json:"reason,omitempty"`
}
+type PromptInfo struct {
+ Text string `json:"text,omitempty"`
+}
+
type ContentInfo struct {
Retention string `json:"retention"`
Included bool `json:"included"`
@@ -98,6 +102,12 @@ type ContentInfo struct {
Truncated bool `json:"truncated,omitempty"`
}
+const (
+ ContentRetentionMetadata = "metadata"
+ ContentRetentionRedacted = "redacted"
+ ContentRetentionFull = "full"
+)
+
type DestinationInfo struct {
Type string `json:"type,omitempty"`
Mode string `json:"mode,omitempty"`
@@ -127,6 +137,7 @@ type Event struct {
MCP *MCPInfo `json:"mcp,omitempty"`
Approval *ApprovalInfo `json:"approval,omitempty"`
Policy *PolicyInfo `json:"policy,omitempty"`
+ Prompt *PromptInfo `json:"prompt,omitempty"`
Content *ContentInfo `json:"content,omitempty"`
Destination *DestinationInfo `json:"destination,omitempty"`
Health *HealthInfo `json:"health,omitempty"`
@@ -204,5 +215,12 @@ func (e Event) Validate() error {
if e.Harness.Name == "" {
return errors.New("harness.name is required")
}
+ if e.Content != nil {
+ switch e.Content.Retention {
+ case ContentRetentionMetadata, ContentRetentionRedacted, ContentRetentionFull:
+ default:
+ return errors.New("content.retention must be metadata, redacted, or full")
+ }
+ }
return nil
}
diff --git a/cli/beacon/internal/endpoint/schema/event_test.go b/cli/beacon/internal/endpoint/schema/event_test.go
index 2a8d81e6..f9ee0a15 100644
--- a/cli/beacon/internal/endpoint/schema/event_test.go
+++ b/cli/beacon/internal/endpoint/schema/event_test.go
@@ -37,12 +37,29 @@ func TestNewEventSetsRequiredInvariants(t *testing.T) {
event.File = &FileInfo{Path: "main.go", Operation: "modify"}
event.Command = &CommandInfo{Command: "go test ./..."}
event.MCP = &MCPInfo{Server: "github", Tool: "get_issue"}
- event.Content = &ContentInfo{Retention: "metadata", Included: false}
+ event.Prompt = &PromptInfo{Text: "Summarize this file"}
+ event.Content = &ContentInfo{Retention: ContentRetentionFull, Included: true}
if err := event.Validate(); err != nil {
t.Fatalf("Validate rejected optional telemetry fields: %v", err)
}
}
+func TestValidateContentRetentionValues(t *testing.T) {
+ for _, retention := range []string{ContentRetentionMetadata, ContentRetentionRedacted, ContentRetentionFull} {
+ t.Run(retention, func(t *testing.T) {
+ event := NewEvent(NewEventOptions{
+ Action: "tool.invoked",
+ Harness: HarnessInfo{Name: "cursor"},
+ })
+ event.Content = &ContentInfo{Retention: retention, Included: retention != ContentRetentionMetadata}
+
+ if err := event.Validate(); err != nil {
+ t.Fatalf("Validate rejected retention %q: %v", retention, err)
+ }
+ })
+ }
+}
+
func TestValidateRejectsMissingOrInvalidRequiredFields(t *testing.T) {
valid := NewEvent(NewEventOptions{
Action: "tool.invoked",
@@ -90,6 +107,11 @@ func TestValidateRejectsMissingOrInvalidRequiredFields(t *testing.T) {
edit: func(e *Event) { e.Harness.Name = "" },
want: "harness.name is required",
},
+ {
+ name: "content retention",
+ edit: func(e *Event) { e.Content = &ContentInfo{Retention: "raw", Included: true} },
+ want: "content.retention must be metadata, redacted, or full",
+ },
}
for _, tt := range tests {
diff --git a/cli/beacon/internal/endpoint/wazuh/pack/sample-event.jsonl b/cli/beacon/internal/endpoint/wazuh/pack/sample-event.jsonl
index b27afa6b..541e46bc 100644
--- a/cli/beacon/internal/endpoint/wazuh/pack/sample-event.jsonl
+++ b/cli/beacon/internal/endpoint/wazuh/pack/sample-event.jsonl
@@ -1,2 +1,2 @@
{"timestamp":"2026-05-11T22:20:00Z","vendor":"beacon","product":"endpoint-agent","schema_version":"1.0","event":{"kind":"agent_runtime","action":"agent.detected","category":"validation"},"severity":"info","endpoint":{"hostname":"example-mac","os":"darwin","agent_version":"0.1.0"},"user":{"name":"local-user"},"harness":{"name":"test_harness","version":"test"},"destination":{"type":"wazuh","mode":"localfile","status":"configured"},"message":"Beacon endpoint Wazuh validation event"}
-{"timestamp":"2026-05-11T22:21:00Z","vendor":"beacon","product":"endpoint-agent","schema_version":"1.0","event":{"kind":"agent_runtime","action":"command.executed","category":"command"},"severity":"info","endpoint":{"hostname":"example-mac","os":"darwin","agent_version":"0.1.0"},"user":{"name":"local-user"},"harness":{"name":"cursor"},"session":{"id":"conversation-1","working_directory":"/Users/local-user/repo"},"tool":{"name":"Shell","command":"go test ./..."},"command":{"command":"go test ./..."},"content":{"retention":"metadata","included":false},"message":"Shell command executed"}
+{"timestamp":"2026-05-11T22:21:00Z","vendor":"beacon","product":"endpoint-agent","schema_version":"1.0","event":{"kind":"agent_runtime","action":"command.executed","category":"command"},"severity":"info","endpoint":{"hostname":"example-mac","os":"darwin","agent_version":"0.1.0"},"user":{"name":"local-user"},"harness":{"name":"cursor"},"session":{"id":"conversation-1","working_directory":"/Users/local-user/repo"},"tool":{"name":"Shell","command":"go test ./..."},"command":{"command":"go test ./..."},"content":{"retention":"full","included":true},"message":"Shell command executed"}
diff --git a/cli/beacon/internal/endpoint/wazuh/wazuh_test.go b/cli/beacon/internal/endpoint/wazuh/wazuh_test.go
index 9ec8dd42..294ecd50 100644
--- a/cli/beacon/internal/endpoint/wazuh/wazuh_test.go
+++ b/cli/beacon/internal/endpoint/wazuh/wazuh_test.go
@@ -37,7 +37,7 @@ func TestRulesCoverAgentWorkflowActions(t *testing.T) {
}
}
sample := mustRead("pack/sample-event.jsonl")
- if !strings.Contains(sample, `"content":{"retention":"metadata","included":false}`) {
- t.Fatalf("sample event missing metadata retention: %s", sample)
+ if !strings.Contains(sample, `"content":{"retention":"full","included":true}`) {
+ t.Fatalf("sample event missing full retention: %s", sample)
}
}
diff --git a/cli/beacon/internal/endpoint/writer/writer.go b/cli/beacon/internal/endpoint/writer/writer.go
index e83e77b3..cd929dd2 100644
--- a/cli/beacon/internal/endpoint/writer/writer.go
+++ b/cli/beacon/internal/endpoint/writer/writer.go
@@ -130,6 +130,9 @@ func SanitizeEvent(event schema.Event, maxBytes int) schema.Event {
if event.Policy != nil {
event.Policy.Reason = redact(truncate(event.Policy.Reason, 4096))
}
+ if event.Prompt != nil {
+ event.Prompt.Text = redact(truncate(event.Prompt.Text, 4096))
+ }
if event.Raw != nil {
event.Raw = sanitizeMap(event.Raw)
}
diff --git a/cli/beacon/internal/endpoint/writer/writer_test.go b/cli/beacon/internal/endpoint/writer/writer_test.go
index 184fd894..d0adcb6b 100644
--- a/cli/beacon/internal/endpoint/writer/writer_test.go
+++ b/cli/beacon/internal/endpoint/writer/writer_test.go
@@ -169,6 +169,7 @@ func TestSanitizeEventRedactsToolPolicyAndRawValues(t *testing.T) {
Path: strings.Repeat("p", 3000),
}
event.Policy = &schema.PolicyInfo{Reason: "api_key=policy-secret"}
+ event.Prompt = &schema.PromptInfo{Text: "token=prompt-secret"}
event.Raw = map[string]interface{}{
"nested": map[string]interface{}{"token": "token=raw-secret"},
}
@@ -179,7 +180,7 @@ func TestSanitizeEventRedactsToolPolicyAndRawValues(t *testing.T) {
t.Fatalf("marshal sanitized event: %v", err)
}
text := string(data)
- for _, secret := range []string{"message-secret", "command-secret", "policy-secret", "raw-secret"} {
+ for _, secret := range []string{"message-secret", "command-secret", "policy-secret", "prompt-secret", "raw-secret"} {
if strings.Contains(text, secret) {
t.Fatalf("secret %q was not redacted: %s", secret, text)
}
diff --git a/collector-builder/exporter/beaconjsonexporter/README.md b/collector-builder/exporter/beaconjsonexporter/README.md
index 1ba1383b..e6213781 100644
--- a/collector-builder/exporter/beaconjsonexporter/README.md
+++ b/collector-builder/exporter/beaconjsonexporter/README.md
@@ -14,8 +14,9 @@ Required behavior:
`schema_version=1.0` event contract.
- Identify Claude Cowork OTLP resources and map prompts, tool/MCP calls, file
access, approval decisions, API usage, token counts, costs, and errors into
- metadata-first endpoint events.
-- Drop or summarize prompt/content fields by default.
+ Beacon endpoint events.
+- Include configured content fields by default, with `metadata` and `redacted`
+ modes available for stricter deployments.
- Redact common secrets and cap event size before writing.
- Emit health failure events when write failures occur.
diff --git a/collector-builder/exporter/beaconjsonexporter/config.go b/collector-builder/exporter/beaconjsonexporter/config.go
index 98f54834..8b03b61f 100644
--- a/collector-builder/exporter/beaconjsonexporter/config.go
+++ b/collector-builder/exporter/beaconjsonexporter/config.go
@@ -21,7 +21,7 @@ func createDefaultConfig() *Config {
MaxEventBytes: defaultMaxEventBytes,
RotateBytes: defaultRotateBytes,
RedactSecrets: true,
- ContentRetention: "metadata",
+ ContentRetention: "full",
}
}
diff --git a/collector-builder/exporter/beaconjsonexporter/event.go b/collector-builder/exporter/beaconjsonexporter/event.go
index a52e25fa..7052c240 100644
--- a/collector-builder/exporter/beaconjsonexporter/event.go
+++ b/collector-builder/exporter/beaconjsonexporter/event.go
@@ -70,6 +70,10 @@ type approvalInfo struct {
Reason string `json:"reason,omitempty"`
}
+type promptInfo struct {
+ Text string `json:"text,omitempty"`
+}
+
type contentInfo struct {
Retention string `json:"retention"`
Included bool `json:"included"`
@@ -93,6 +97,7 @@ type beaconEvent struct {
Command *commandInfo `json:"command,omitempty"`
MCP *mcpInfo `json:"mcp,omitempty"`
Approval *approvalInfo `json:"approval,omitempty"`
+ Prompt *promptInfo `json:"prompt,omitempty"`
Content *contentInfo `json:"content,omitempty"`
Model string `json:"model,omitempty"`
Repository string `json:"repository,omitempty"`
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter.go b/collector-builder/exporter/beaconjsonexporter/exporter.go
index 5a15a98e..a7f03403 100644
--- a/collector-builder/exporter/beaconjsonexporter/exporter.go
+++ b/collector-builder/exporter/beaconjsonexporter/exporter.go
@@ -33,7 +33,7 @@ func newExporter(raw component.Config, set exporter.Settings) (*beaconExporter,
cfg.RotateBytes = defaultRotateBytes
}
if cfg.ContentRetention == "" {
- cfg.ContentRetention = "metadata"
+ cfg.ContentRetention = "full"
}
if err := cfg.Validate(); err != nil {
return nil, err
@@ -215,7 +215,11 @@ func isCodexInternalSpan(name string) bool {
func (e *beaconExporter) eventFromMetric(resourceAttrs map[string]interface{}, metric pmetric.Metric) beaconEvent {
attrs := mergeMaps(resourceAttrs, map[string]interface{}{})
- event := newBeaconEvent(firstString(attrs, "beacon.event.action", "event.action", "metric.observed"), "metric", "info", harnessName(attrs, metric.Name()), time.Now().UTC())
+ action := firstString(attrs, "beacon.event.action", "event.action")
+ if action == "" {
+ action = "metric.observed"
+ }
+ event := newBeaconEvent(action, "metric", "info", harnessName(attrs, metric.Name()), time.Now().UTC())
event.Message = metric.Name()
e.populateCommon(&event, attrs)
event.Raw = e.rawPayload(attrs, map[string]interface{}{
@@ -273,6 +277,11 @@ func (e *beaconExporter) populateCommon(event *beaconEvent, attrs map[string]int
Reason: firstString(attrs, "approval.reason", "policy.reason"),
}
}
+ if e.cfg.ContentRetention != "metadata" && event.Event.Category == "prompt" {
+ if text := firstString(attrs, "gen_ai.prompt", "prompt", "user_prompt", "input.prompt"); text != "" {
+ event.Prompt = &promptInfo{Text: text}
+ }
+ }
event.Content = &contentInfo{Retention: e.cfg.ContentRetention, Included: e.cfg.ContentRetention != "metadata", Redacted: e.cfg.ContentRetention == "redacted"}
}
@@ -415,9 +424,13 @@ func normalizeHarnessName(name string) string {
func inferAction(attrs map[string]interface{}, fallback string) string {
tool := strings.ToLower(firstString(attrs, "tool.name", "gen_ai.tool.name", "mcp.tool.name"))
- text := strings.ToLower(fallback + " " + tool)
+ text := strings.ToLower(strings.Join([]string{
+ fallback,
+ tool,
+ firstString(attrs, "event.name", "codex.op", "rpc.method"),
+ }, " "))
switch {
- case strings.Contains(text, "prompt"):
+ case strings.Contains(text, "prompt") || strings.Contains(text, "user_input"):
return "prompt.submitted"
case strings.Contains(text, "mcp"):
return "mcp.tool_invoked"
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter_test.go b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
index d5f619d7..30b7a91d 100644
--- a/collector-builder/exporter/beaconjsonexporter/exporter_test.go
+++ b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
@@ -10,6 +10,7 @@ import (
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/pdata/plog"
+ "go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
)
@@ -24,6 +25,29 @@ func TestConfigValidateRequiresPath(t *testing.T) {
}
}
+func TestDefaultConfigUsesFullRetention(t *testing.T) {
+ cfg := createDefaultConfig()
+ if cfg.ContentRetention != "full" {
+ t.Fatalf("ContentRetention = %q, want full", cfg.ContentRetention)
+ }
+}
+
+func TestNewExporterDefaultsEmptyRetentionToFull(t *testing.T) {
+ cfg := &Config{
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ }
+ exp, err := newExporter(cfg, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+ if exp.cfg.ContentRetention != "full" {
+ t.Fatalf("ContentRetention = %q, want full", exp.cfg.ContentRetention)
+ }
+}
+
func TestConsumeLogsWritesBeaconJSONL(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
@@ -76,6 +100,70 @@ func TestConsumeLogsWritesBeaconJSONL(t *testing.T) {
}
}
+func TestConsumeLogsMapsPromptForFullRetention(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ exp, err := newExporter(&Config{
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ ContentRetention: "full",
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+
+ logs := plog.NewLogs()
+ rl := logs.ResourceLogs().AppendEmpty()
+ sl := rl.ScopeLogs().AppendEmpty()
+ rec := sl.LogRecords().AppendEmpty()
+ rec.Body().SetStr("prompt submitted")
+ rec.Attributes().PutStr("beacon.event.action", "prompt.submitted")
+ rec.Attributes().PutStr("gen_ai.prompt", "summarize token=prompt-secret")
+
+ if err := exp.consumeLogs(context.Background(), logs); err != nil {
+ t.Fatalf("consumeLogs returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read runtime log: %v", err)
+ }
+ var event beaconEvent
+ if err := json.Unmarshal([]byte(strings.TrimSpace(string(data))), &event); err != nil {
+ t.Fatalf("unmarshal event: %v", err)
+ }
+ if event.Prompt == nil || event.Prompt.Text != "summarize token=[REDACTED]" {
+ t.Fatalf("prompt = %#v, want redacted typed prompt", event.Prompt)
+ }
+}
+
+func TestMetadataRetentionOmitsTypedPrompt(t *testing.T) {
+ exp, err := newExporter(&Config{
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ ContentRetention: "metadata",
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+ attrs := map[string]interface{}{
+ "beacon.event.action": "prompt.submitted",
+ "gen_ai.prompt": "summarize this file",
+ }
+ logs := plog.NewLogs()
+ record := logs.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
+ for key, value := range attrs {
+ record.Attributes().PutStr(key, value.(string))
+ }
+
+ event := exp.eventFromLog(nil, record)
+ if event.Prompt != nil {
+ t.Fatalf("metadata retention should omit prompt: %#v", event.Prompt)
+ }
+}
+
func TestEventCategoryInfersFromAction(t *testing.T) {
tests := map[string]string{
"tool.invoked": "tool",
@@ -97,6 +185,100 @@ func TestEventCategoryInfersFromAction(t *testing.T) {
}
}
+func TestEventFromMetricDefaultsToObservedAction(t *testing.T) {
+ exp, err := newExporter(&Config{
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ ContentRetention: "metadata",
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+
+ metrics := pmetric.NewMetrics()
+ metric := metrics.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
+ metric.SetName("codex.run.token_usage")
+
+ event := exp.eventFromMetric(map[string]interface{}{"service.name": "codex-cli"}, metric)
+ if event.Event.Action != "metric.observed" {
+ t.Fatalf("metric action = %q, want metric.observed", event.Event.Action)
+ }
+ if event.Event.Category != "metric" {
+ t.Fatalf("metric category = %q, want metric", event.Event.Category)
+ }
+ if event.Harness.Name != "codex_cli" {
+ t.Fatalf("harness = %q, want codex_cli", event.Harness.Name)
+ }
+ if event.Raw["metric_name"] != "codex.run.token_usage" {
+ t.Fatalf("metric raw payload = %#v", event.Raw)
+ }
+}
+
+func TestInferActionMapsCodexUserInputToPrompt(t *testing.T) {
+ attrs := map[string]interface{}{"service.name": "codex_cli_rs"}
+ if got := inferAction(attrs, "op.dispatch.user_input_with_turn_context"); got != "prompt.submitted" {
+ t.Fatalf("inferAction() = %q, want prompt.submitted", got)
+ }
+}
+
+func TestInferActionMapsCodexOpAttributeToPrompt(t *testing.T) {
+ attrs := map[string]interface{}{
+ "service.name": "codex_cli_rs",
+ "codex.op": "user_input_with_turn_context",
+ }
+ if got := inferAction(attrs, "op.dispatch"); got != "prompt.submitted" {
+ t.Fatalf("inferAction() = %q, want prompt.submitted", got)
+ }
+}
+
+func TestEventFromSpanMapsCodexUserInputToPrompt(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ exp, err := newExporter(&Config{
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ ContentRetention: "full",
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+
+ span := testSpan("op.dispatch.user_input_with_turn_context")
+ span.Attributes().PutStr("prompt", "summarize token=codex-secret")
+
+ traces := ptrace.NewTraces()
+ rs := traces.ResourceSpans().AppendEmpty()
+ rs.Resource().Attributes().PutStr("service.name", "codex-cli")
+ span.CopyTo(rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty())
+
+ if err := exp.consumeTraces(context.Background(), traces); err != nil {
+ t.Fatalf("consumeTraces returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read runtime log: %v", err)
+ }
+ var event beaconEvent
+ if err := json.Unmarshal([]byte(strings.TrimSpace(string(data))), &event); err != nil {
+ t.Fatalf("unmarshal event: %v", err)
+ }
+ if event.Event.Action != "prompt.submitted" {
+ t.Fatalf("span action = %q, want prompt.submitted", event.Event.Action)
+ }
+ if event.Event.Category != "prompt" {
+ t.Fatalf("span category = %q, want prompt", event.Event.Category)
+ }
+ if event.Harness.Name != "codex_cli" {
+ t.Fatalf("harness = %q, want codex_cli", event.Harness.Name)
+ }
+ if event.Prompt == nil || event.Prompt.Text != "summarize token=[REDACTED]" {
+ t.Fatalf("prompt = %#v, want redacted Codex prompt", event.Prompt)
+ }
+}
+
func TestMetadataRetentionDropsRawAttributes(t *testing.T) {
exp, err := newExporter(&Config{
Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
diff --git a/collector-builder/exporter/beaconjsonexporter/writer.go b/collector-builder/exporter/beaconjsonexporter/writer.go
index 63c7d782..5353b1f1 100644
--- a/collector-builder/exporter/beaconjsonexporter/writer.go
+++ b/collector-builder/exporter/beaconjsonexporter/writer.go
@@ -74,6 +74,9 @@ func (w jsonlWriter) sanitize(event beaconEvent) beaconEvent {
if event.Approval != nil {
event.Approval.Reason = w.cleanString(event.Approval.Reason, 4096)
}
+ if event.Prompt != nil {
+ event.Prompt.Text = w.cleanString(event.Prompt.Text, 4096)
+ }
if event.Raw != nil {
event.Raw = w.sanitizeMap(event.Raw)
}