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
Add prompt.id to the event schema
Claude18d6b1184c85
diff --git a/CLAUDE.md b/CLAUDE.mdindex 55f25f5b..00019dcd 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -539,7 +539,7 @@ unpacked through Chrome's developer mode.- Preserve optional event fields for agent-native metadata (`session`, `trace`, `tool`, `file`, `command`, `mcp`, `approval`, `content`, `model`, `repository`, and `branch`) without changing existing required field semantics.- Reading a runtime's own on-disk session store is a `poll` collection path, not a new method: it is a pull that sees committed records after the fact, which is what `poll` means. fx is the case that exercises it (`cli/beacon/internal/fxsession`); a future runtime with the same shape uses `poll` too rather than adding a fifth value to a release-contract field. The token aggregator relies on that marker: when one session (endpoint, normalized harness, session id) has usage from both a live method and `poll`, `preferLiveOverPoll` in `cli/beacon/internal/tokens/tokens.go` keeps live usage authoritative from the first event of that live channel in the session and drops the backfill's copies from then on, so a poll mapper must keep the runtime's own session id and real record timestamps rather than deduplicating against the live log itself.- Set the provenance markers on every new collection path. `harness.collection_method` (`hook`, `otlp`, `plugin`, `poll`) records the mechanism; `event.fidelity` (`observed`, `inferred`) records whether the source named the action or Beacon derived it. Both are defined in `pkg/asymptoteobserve/provenance.go` and are the only sanctioned way to express that difference — do not add per-runtime confidence fields, and do not leave a derived action unmarked. A new plugin-shaped runtime must be added to `CollectionMethodForPlatform`, whose default is `hook`. An action synthesized from an adjacent observation, such as an approval built from a pre-tool notification on a runtime with no approval hook, is `inferred`.-- Keep event identity derivable rather than asserted. `gen_ai.tool.call.id` carries the runtime's own name for one tool invocation, promoted on every capture path from the shared alias list in `pkg/asymptoteobserve.ToolCallIDKeys`; a new runtime adds its spelling there rather than in a mapper. `event.id` is a deterministic UUID derived by `EventIDForLine` from the event about to be written, so both capture paths name one action the same way. Its namespace constant and derivation are a contract: changing either renames every event ID Beacon has written, and a test pins the value.+- Keep event identity derivable rather than asserted. `gen_ai.tool.call.id` carries the runtime's own name for one tool invocation, promoted on every capture path from the shared alias list in `pkg/asymptoteobserve.ToolCallIDKeys`; a new runtime adds its spelling there rather than in a mapper. `prompt.id` names the turn an event belongs to (one user prompt and everything done for it, until the next prompt) and is promoted the same way from `asymptoteobserve.PromptIDKeys` (hook envelope, OTLP attributes, `beacon.prompt.id`); session-store mappers set it from the turn they are reading. OTel GenAI has no turn attribute, so the name is Claude Code's own; a spelling joins the list only when the runtime's value is exactly one prompt (Copilot's per-model-call turn ids are excluded). A present `prompt` object no longer means "this is a prompt": test `prompt.text` or the category. `event.id` is a deterministic UUID derived by `EventIDForLine` from the event about to be written, so both capture paths name one action the same way. Its namespace constant and derivation are a contract: changing either renames every event ID Beacon has written, and a test pins the value.- Keep `gen_ai.usage` as the single canonical token-usage representation: normalize all runtime token telemetry (span attributes, metric datapoints, legacy `llm.usage.*` aliases) into it, mirror OTel GenAI semconv JSON names exactly, and never add parallel or per-harness token fields. `gen_ai.usage.cache_creation.ephemeral_1h_input_tokens` (optional, Anthropic's own name) is the subset of `cache_creation.input_tokens` written with a one-hour TTL: a breakdown like `reasoning` inside output, never added to a total, built with `asymptoteobserve.NewCacheCreationUsage` (clamps it to the write count) and differenced with `GenAIUsageCacheCreationInfo.Minus`. It is set by Claude Code session files, Pi-family `cacheWrite1h` and the browser extension's Claude adapter; Claude Code's OTLP export has no split, and reports price unsplit writes at the five-minute rate. `gen_ai.usage.cost_usd` carries runtime-reported cost only and is never written from a price list; list-price estimates are computed only at report time from the embedded catalog (`cli/beacon/internal/pricing`), are always labeled as estimates, and are never stored in events.- `cli/beacon/internal/pricing` estimates list-price cost for reports: integer-microdollar math over the gen_ai.usage counts (disjoint input/output/cache read/cache write, a one-hour write subset, reasoning inside output), long-context bands only for a single request, and a strict model-name ladder (exact, canonical via `NormalizeModelName`, dotted version, Bedrock route prefix, then stripping a `[1m]` marker, snapshot date or effort suffix) that leaves a model unpriced rather than guess, including when two entries tie with different prices. Its `catalog.json` is embedded, offline and report-time only (hooks never import it); it is generated from LiteLLM's MIT-licensed `model_prices_and_context_window.json` and records the upstream URL, commit and fetch/generation dates. Regenerate with `cd cli/beacon && go run ./internal/pricing/internal/gen` (resolves LiteLLM's main with `git ls-remote` and fetches that commit; `-src`/`-commit` for a local copy) and review the one-model-per-line diff; the generator never runs in builds or tests. Operators price what the catalog cannot (internal models, new releases, gateway aliases, negotiated rates) in a local overrides file, `<BaseDir>/pricing/overrides.json` (`pricing.DefaultOverridesPath`, user or system mode; `--pricing-file` on `beacon token-usage` and `beacon pricing` names another), schema `beacon.pricing.overrides/v1`, documented in `docs/cli/pricing.mdx`. It is offline and Beacon never writes it: the CLI reads it per run, and the dashboard re-reads it per `/api/tokens` request, read-only, falling back to the catalog with `pricing.overrides.error` when it is invalid (the CLI fails instead). Rates are USD per MTok converted exactly to microdollars; zero, negative, quoted, sub-microdollar, absurd, unknown and duplicate keys are refused with the key named. `Pricer.Lookup` runs the same ladder over the file's names first and a row replaces the catalog row whole (omitted cache rates are unpublished, priced by the usual fallbacks); aliases map a reported name to an exact row or catalog key. Reports record `source` (`override`/`catalog`), `alias`, and the file's path and SHA-256. `beacon pricing show|list|info|validate` (`cli/beacon/cmd/pricing.go`) inspects resolution, the catalog, its provenance and the file.- When adding a new signal, include stable identifiers/counts/hashes alongside any retained raw content, and route raw fields through redaction, sanitization, truncation, and event-size controls.diff --git a/cli/beacon/internal/endpoint/asymptote/asymptote_test.go b/cli/beacon/internal/endpoint/asymptote/asymptote_test.goindex a386345a..5cbb0f1c 100644--- a/cli/beacon/internal/endpoint/asymptote/asymptote_test.go+++ b/cli/beacon/internal/endpoint/asymptote/asymptote_test.go@@ -218,7 +218,7 @@ func TestRenderVectorConfigSelectsMetadataOnlyTransforms(t *testing.T) {`inputs = ["beacon_runtime_metadata"]`,`inputs = ["beacon_inventory_metadata"]`,`drop_on_abort = true`,- `del(event.prompt)`,+ `del(event.prompt.text)`,`del(event.command.output)`,`del(event.file.diff)`,`del(event.gen_ai.tool.call.arguments)`,diff --git a/cli/beacon/internal/endpoint/asymptote/pack/metadata-transforms.toml b/cli/beacon/internal/endpoint/asymptote/pack/metadata-transforms.tomlindex 3ed19d3f..fe5eb35d 100644--- a/cli/beacon/internal/endpoint/asymptote/pack/metadata-transforms.toml+++ b/cli/beacon/internal/endpoint/asymptote/pack/metadata-transforms.toml@@ -4,7 +4,11 @@ inputs = ["beacon_runtime", "beacon_backfill"]drop_on_abort = truesource = '''event = parse_json!(string!(.message))-del(event.prompt)+# prompt.id names the turn an event belongs to and is kept; the prompt's text is content.+del(event.prompt.text)+if is_object(event.prompt) && is_empty(object!(event.prompt)) {+ del(event.prompt)+}del(event.message)del(event.raw)del(event.command.output)diff --git a/cli/beacon/internal/endpoint/dashboard/events.go b/cli/beacon/internal/endpoint/dashboard/events.goindex c21bab5a..797e19bc 100644--- a/cli/beacon/internal/endpoint/dashboard/events.go+++ b/cli/beacon/internal/endpoint/dashboard/events.go@@ -382,7 +382,9 @@ func normalizedSessionUser(event schema.Event) string {func isPromptEvent(event schema.Event) bool {action := normalizedLifecycleValue(event.Event.Action)- return strings.EqualFold(event.Event.Category, "prompt") || strings.Contains(action, "prompt") || event.Prompt != nil+ // Prompt text, not the prompt object: every event of a turn carries prompt.id, and a tool call+ // is not a prompt because it names the prompt it belongs to.+ return strings.EqualFold(event.Event.Category, "prompt") || strings.Contains(action, "prompt") || (event.Prompt != nil && event.Prompt.Text != "")}func isLifecycleSessionEvent(event schema.Event) bool {diff --git a/cli/beacon/internal/endpoint/dashboard/prompt_id_test.go b/cli/beacon/internal/endpoint/dashboard/prompt_id_test.gonew file mode 100644index 00000000..0f770fae--- /dev/null+++ b/cli/beacon/internal/endpoint/dashboard/prompt_id_test.go@@ -0,0 +1,52 @@+package dashboard++import (+ "path/filepath"+ "testing"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"+)++// Every event of a turn carries prompt.id, so a prompt object is no longer the mark of a prompt.+// A session whose tool calls and responses name their prompt still has one prompt, and the prompt+// it shows is the prompt's text rather than whatever came first with an id.+func TestPromptIDOnEveryEventDoesNotMakeThemPrompts(t *testing.T) {+ agentMessage := testSchemaEvent("2026-05-13T01:00:00Z", "claude_code", "agent.message", "session", "repo-a")+ agentMessage.Prompt = &schema.PromptInfo{ID: "p-1"}+ if isPromptEvent(agentMessage) {+ t.Fatal("an agent message naming its prompt was classified as a prompt")+ }+ prompt := testSchemaEvent("2026-05-13T01:00:01Z", "claude_code", "prompt.submitted", "prompt", "repo-a")+ prompt.Prompt = &schema.PromptInfo{ID: "p-1", Text: "Investigate the dashboard"}+ if !isPromptEvent(prompt) {+ t.Fatal("the prompt itself was not classified as a prompt")+ }++ path := filepath.Join(t.TempDir(), "runtime.jsonl")+ events := []schema.Event{+ testSchemaEvent("2026-05-13T01:00:00Z", "claude_code", "session.activity", "session", "repo-a"),+ prompt,+ testSchemaEvent("2026-05-13T01:00:02Z", "claude_code", "command.executed", "command", "repo-a"),+ agentMessage,+ }+ events[0].Prompt = &schema.PromptInfo{ID: "p-0"}+ events[2].Command = &schema.CommandInfo{Command: "go test ./..."}+ events[2].Prompt = &schema.PromptInfo{ID: "p-1"}+ events[3].Timestamp = "2026-05-13T01:00:03Z"+ for i := range events {+ events[i].Session = &schema.SessionInfo{ID: "session-a"}+ }+ writeTestLog(t, path, marshalEvents(t, events...)...)++ result, err := ReadSessions(path, EventQuery{Limit: 10})+ if err != nil {+ t.Fatalf("ReadSessions returned error: %v", err)+ }+ if len(result.Sessions) != 1 {+ t.Fatalf("sessions = %d, want 1", len(result.Sessions))+ }+ session := result.Sessions[0]+ if session.OriginalPrompt != "Investigate the dashboard" || session.PromptCount != 1 {+ t.Fatalf("session prompt = %q count %d, want the prompt's text once", session.OriginalPrompt, session.PromptCount)+ }+}diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.jsindex 11584318..55975651 100644--- a/cli/beacon/internal/endpoint/dashboard/static/app.js+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js@@ -2143,7 +2143,7 @@ function sessionEventCategory(event) {if (event.file) return "file";if (event.mcp) return "mcp";if (event.approval || event.policy) return "approval";- if (event.prompt) return "prompt";+ if (event.prompt?.text) return "prompt";if (event.tool) return "tool";return "other";}diff --git a/cli/beacon/internal/endpoint/elastic/pack/component-template-mappings.json b/cli/beacon/internal/endpoint/elastic/pack/component-template-mappings.jsonindex 53dbdbf9..c0ae14fa 100644--- a/cli/beacon/internal/endpoint/elastic/pack/component-template-mappings.json+++ b/cli/beacon/internal/endpoint/elastic/pack/component-template-mappings.json@@ -100,6 +100,7 @@},"prompt": {"properties": {+ "id": { "type": "keyword" },"text": { "type": "match_only_text" }}},diff --git a/docs/architecture/architecture.mdx b/docs/architecture/architecture.mdxindex c480dd56..24ebf156 100644--- a/docs/architecture/architecture.mdx+++ b/docs/architecture/architecture.mdx@@ -91,6 +91,8 @@ Beacon writes one JSON object per line to the [runtime JSONL log](/concepts/coreEvents from every surface share session, run, tool-call, and event identifiers, so one agent session reconstructs as an ordered timeline instead of disconnected records. `gen_ai.tool.call.id` carries the runtime's own name for a tool invocation, and `event.id` is derived from the event itself, so a hook and an OTLP capture of the same action agree on identity.+`prompt.id` names the turn an event belongs to: one user prompt and everything the agent did for it, until the next prompt. It is set on the prompt and on every tool call, command, file change, approval, response and token count that followed, so filtering on one value returns the whole turn. OpenTelemetry's GenAI conventions define no attribute for this, so Beacon uses the name the runtimes do, and normalizes each runtime's own spelling of its identifier into it: Claude Code's `prompt.id` (and the matching `promptId` in its transcripts), Gemini CLI's `prompt_id`, Codex's `turn_id`, Cursor's `generation_id`, and Muse Code's and Kimi Code's `turn_id`. The value is the runtime's own, so it also matches that runtime's logs. It is unique within a session, so a turn is identified by harness, `session.id` and `prompt.id` together. Runtimes that expose no per-turn identifier leave the field empty, and metadata-only forwarding keeps it while removing the prompt text.+The local [dashboard](/concepts/core-concepts#dashboard) reads recent runtime logsover a loopback-only service for rollout validation and investigation, withsession timelines, activity summaries, Detections and Findings, Token Usage,diff --git a/docs/cli/endpoint-connect.mdx b/docs/cli/endpoint-connect.mdxindex 2c92ac57..8558e84c 100644--- a/docs/cli/endpoint-connect.mdx+++ b/docs/cli/endpoint-connect.mdx@@ -73,7 +73,7 @@ The onboarding wizard records one of two modes. `connect` uses that choice unles| Mode | Forwarded data ||------|----------------|| `standard` | The complete locally sanitized event, including retained prompts, responses, reasoning, tool arguments/results, command output, and diffs. Existing local redaction and size limits still apply. |-| `metadata-only` | Omits prompts, responses, reasoning, tool arguments/results, command output, raw event fields, diffs, inventory file contents, and MCP definitions. Stable ids, hashes, byte counts, actions, timestamps, harness/session/trace identity, token usage, commands, file paths, and other structured metadata remain. |+| `metadata-only` | Omits prompts, responses, reasoning, tool arguments/results, command output, raw event fields, diffs, inventory file contents, and MCP definitions. Stable ids, hashes, byte counts, actions, timestamps, harness/session/trace identity, the `prompt.id` that groups a turn, token usage, commands, file paths, and other structured metadata remain. |The transform runs locally in Vector before batching, buffering, or HTTPS upload.Changing modes requires rerunning `beacon endpoint connect`; the rendered config anddiff --git a/docs/cli/rules-fields.mdx b/docs/cli/rules-fields.mdxindex 4cab77e2..cfc7001e 100644--- a/docs/cli/rules-fields.mdx+++ b/docs/cli/rules-fields.mdx@@ -23,6 +23,7 @@ Threat-rule expressions bind each Beacon event as `e`. Field paths mirror the ev| `e.command.command` | Match executed command text || `e.file.path` | Match a file path || `e.prompt.text` | Match prompt text when retained |+| `e.prompt.id` | Group the events of one turn: the prompt and everything the agent did for it || `e.gen_ai.tool.call.result_text` | Match text a file read, web fetch, or MCP tool returned, when retained (derived by the engine; empty for other actions) || `e.gen_ai.usage.input_tokens` | Match normalized token usage fields |diff --git a/pkg/asymptoteobserve/event.go b/pkg/asymptoteobserve/event.goindex 02484016..dc56fe99 100644--- a/pkg/asymptoteobserve/event.go+++ b/pkg/asymptoteobserve/event.go@@ -223,7 +223,15 @@ type PolicyInfo struct {Reason string `json:"reason,omitempty"`}+// PromptInfo describes the user prompt an event belongs to.+//+// Text is set only on the prompt itself. ID is set on every event the prompt led to, from the+// prompt through the agent's response until the next prompt, so one value selects a whole turn.+// It is the runtime's own identifier, normalized from its spelling by PromptIDKeys; a present+// prompt object therefore no longer means the event is a prompt -- Text, or the prompt category,+// says that.type PromptInfo struct {+ ID string `json:"id,omitempty"`Text string `json:"text,omitempty"`}diff --git a/pkg/asymptoteobserve/identity.go b/pkg/asymptoteobserve/identity.goindex 670c81b7..bb4c67c1 100644--- a/pkg/asymptoteobserve/identity.go+++ b/pkg/asymptoteobserve/identity.go@@ -6,6 +6,8 @@ import ("encoding/json""fmt""io"+ "math"+ "strconv""strings")@@ -39,6 +41,101 @@ var ToolCallIDKeys = []string{"cursor.grok_bot.tool_call.id",}+// PromptIDKeys are the names a runtime uses for the identifier it assigns to one+// user prompt and all the work done for it, until the next prompt -- what a+// person would call a turn. They are promoted to prompt.id on every capture+// path from this single list, the way ToolCallIDKeys is promoted to+// gen_ai.tool.call.id.+//+// OpenTelemetry's GenAI conventions define no attribute for this, so the field+// takes the name the runtimes themselves use: Claude Code's prompt.id, which it+// documents as correlating "a user prompt with all subsequent events until the+// next prompt", and which Gemini CLI spells prompt_id with the same meaning.+//+// A spelling belongs here only when the runtime's value means exactly that.+// Each entry names the runtime that writes it and the evidence:+//+// - prompt.id: Claude Code OTLP events. The same UUID is written as promptId+// on the transcript's prompt and tool-result entries.+// - promptId: Claude Code session transcripts.+// - prompt_id: Gemini CLI OTLP events.+// - turn.id: Codex OTLP turn spans.+// - turn_id: Codex hooks ("the active Codex turn id" on every turn-scoped+// hook), Muse Code hooks, and Kimi Code hooks, where it is a number.+// - generation_id: Cursor hooks ("the current generation that changes with+// every user message"; conversation_id is the session).+//+// GitHub Copilot's turn ids are deliberately absent: Copilot opens a new turn+// for each model call inside one prompt, so its turn id is finer than a prompt.+//+// Canonical names come first so an explicitly mapped value always beats a+// runtime-native one; no payload carries two of the native names.+var PromptIDKeys = []string{+ "prompt.id",+ "beacon.prompt.id",+ "promptId",+ "prompt_id",+ "turn.id",+ "turn_id",+ "generation_id",+}++// PromptIDFrom reads the first prompt identifier in m under PromptIDKeys.+//+// Strings are trimmed. Integral numbers are accepted and rendered in base 10,+// because Kimi Code numbers its turns and a decoded JSON payload holds that as+// a float64. Anything else -- a fractional number, an object, a bool -- is not+// an identifier and is skipped.+func PromptIDFrom(m map[string]interface{}) string {+ for _, key := range PromptIDKeys {+ if id := identifierString(m[key]); id != "" {+ return id+ }+ }+ return ""+}++func identifierString(value interface{}) string {+ switch typed := value.(type) {+ case string:+ return strings.TrimSpace(typed)+ case float64:+ if typed == math.Trunc(typed) && !math.IsInf(typed, 0) && math.Abs(typed) < 1<<53 {+ return strconv.FormatInt(int64(typed), 10)+ }+ case int:+ return strconv.Itoa(typed)+ case int64:+ return strconv.FormatInt(typed, 10)+ case json.Number:+ if n, err := typed.Int64(); err == nil {+ return strconv.FormatInt(n, 10)+ }+ }+ return ""+}++// SetPromptID records the prompt an event belongs to, keeping any prompt text+// already on it. An empty id leaves the event alone.+func SetPromptID(event *Event, id string) {+ id = strings.TrimSpace(id)+ if event == nil || id == "" {+ return+ }+ if event.Prompt == nil {+ event.Prompt = &PromptInfo{}+ }+ event.Prompt.ID = id+}++// PromptID returns the prompt identifier recorded on an event.+func PromptID(event *Event) string {+ if event == nil || event.Prompt == nil {+ return ""+ }+ return strings.TrimSpace(event.Prompt.ID)+}+// eventIDNamespace is the fixed UUID namespace every Beacon event ID is derived// under, so the same event derives the same UUID in any process and any// release. It is an arbitrary constant, not a secret, and must never change:diff --git a/pkg/asymptoteobserve/prompt_id_test.go b/pkg/asymptoteobserve/prompt_id_test.gonew file mode 100644index 00000000..09cdf7ee--- /dev/null+++ b/pkg/asymptoteobserve/prompt_id_test.go@@ -0,0 +1,75 @@+package asymptoteobserve++import (+ "encoding/json"+ "testing"+)++// Every runtime spelling of one prompt's identifier lands in the same field. This is the table the+// alias list exists for: a consumer filters on prompt.id and never learns that Cursor calls it+// generation_id or Codex turn_id.+func TestPromptIDFromNormalizesEveryRuntimeSpelling(t *testing.T) {+ for name, tc := range map[string]struct {+ payload map[string]interface{}+ want string+ }{+ "claude code otlp": {map[string]interface{}{"prompt.id": "7f1c"}, "7f1c"},+ "beacon canonical": {map[string]interface{}{"beacon.prompt.id": "b-1"}, "b-1"},+ "claude code transcript": {map[string]interface{}{"promptId": "7f1c"}, "7f1c"},+ "gemini cli": {map[string]interface{}{"prompt_id": "s########3"}, "s########3"},+ "codex otlp": {map[string]interface{}{"turn.id": "turn-a"}, "turn-a"},+ "codex hooks": {map[string]interface{}{"turn_id": "turn-a"}, "turn-a"},+ "kimi code number": {map[string]interface{}{"turn_id": float64(3)}, "3"},+ "cursor hooks": {map[string]interface{}{"generation_id": "gen-1", "conversation_id": "conv"}, "gen-1"},+ "trimmed": {map[string]interface{}{"turn_id": " t "}, "t"},+ "canonical wins": {map[string]interface{}{"prompt.id": "canon", "generation_id": "native"}, "canon"},+ "json number": {map[string]interface{}{"turn_id": json.Number("12")}, "12"},+ "fractional is not an id": {map[string]interface{}{"turn_id": 1.5}, ""},+ "object is not an id": {map[string]interface{}{"turn_id": map[string]interface{}{"id": "x"}}, ""},+ "bool is not an id": {map[string]interface{}{"turn_id": true}, ""},+ "blank is not an id": {map[string]interface{}{"prompt.id": " ", "turn_id": "next"}, "next"},+ "session id is not a prompt id": {map[string]interface{}{"session_id": "s", "conversation_id": "c"}, ""},+ } {+ t.Run(name, func(t *testing.T) {+ if got := PromptIDFrom(tc.payload); got != tc.want {+ t.Fatalf("PromptIDFrom = %q, want %q", got, tc.want)+ }+ })+ }+}++// GitHub Copilot opens a turn per model call inside one prompt, so its turn id would split one+// prompt's work into several. Its spellings stay out of the list.+func TestPromptIDKeysExcludeCopilotTurnIDs(t *testing.T) {+ for _, key := range PromptIDKeys {+ switch key {+ case "turnId", "github.copilot.turn_id":+ t.Fatalf("PromptIDKeys includes %q, a per-model-call turn id", key)+ }+ }+}++func TestSetPromptIDKeepsPromptText(t *testing.T) {+ event := &Event{Prompt: &PromptInfo{Text: "fix the build"}}+ SetPromptID(event, " p-1 ")+ if event.Prompt.Text != "fix the build" || event.Prompt.ID != "p-1" {+ t.Fatalf("prompt = %#v, want text kept and id p-1", event.Prompt)+ }+ if got := PromptID(event); got != "p-1" {+ t.Fatalf("PromptID = %q, want p-1", got)+ }++ bare := &Event{}+ SetPromptID(bare, "")+ if bare.Prompt != nil {+ t.Fatalf("an empty id created a prompt object: %#v", bare.Prompt)+ }+ SetPromptID(bare, "p-2")+ line, err := json.Marshal(bare.Prompt)+ if err != nil {+ t.Fatal(err)+ }+ if string(line) != `{"id":"p-2"}` {+ t.Fatalf("prompt = %s, want only the id", line)+ }+}diff --git a/spec/threat-rules/FIELDS.md b/spec/threat-rules/FIELDS.mdindex a3596562..464383de 100644--- a/spec/threat-rules/FIELDS.md+++ b/spec/threat-rules/FIELDS.md@@ -119,6 +119,7 @@ Regenerate with `beacon rules fields --markdown > spec/threat-rules/FIELDS.md`.| `e.policy.name` | string || `e.policy.reason` | string || `e.product` | string |+| `e.prompt.id` | string || `e.prompt.text` | string || `e.repository` | string || `e.rpc.response.status_code` | string |