Skip to content

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

fix(cursor): leave cloud agents the desktop app relays unrecorded on the endpoint

shukieshah2946f6e9df51
diff --git a/CLAUDE.md b/CLAUDE.md
index 542a8761..1fb92ca9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -47,7 +47,7 @@ Do not recreate or depend on removed `asymptote` mirror trees. Keep new work foc
Supported runtime surfaces today:
- Claude Code and Codex CLI use local OpenTelemetry settings, and `beacon endpoint install` writes their user-level hooks alongside those settings (`otlpTargetCarriesHook` in `cli/beacon/cmd/endpoint_targets.go`), because Claude's OTLP export has no session lifecycle, file activity, or subagent events and Codex's SessionStart hook supplies the OS-user context its spans lack. Both runtimes' Stop hooks record the turn's final reply from `last_assistant_message` as `agent.message` (Codex through the dedicated `codex-assistant-response` command, since its OTLP export carries no response text and it gets no generic hooks). `beacon endpoint codex sync` is the offline poll backfill from `~/.codex/sessions`; it never reads `~/.codex/auth.json` and cannot approve, deny, or delay tool calls.
-- Cursor hook telemetry for sessions, prompt submission, tool use, command execution, MCP-like tool activity, approval decisions, file edits, and agent reasoning (`afterAgentThought` thinking text recorded as `agent.reasoning` events in the OTel GenAI `gen_ai.output.messages` reasoning-part shape) where hook payloads expose those fields. The Cursor IDE also runs the hooks in the user-level `~/.claude/settings.json`, with Cursor payloads; when Beacon's own `~/.cursor/hooks.json` runs the same hook subcommand and that entry's matcher selects the call's tool, that Claude Code run writes nothing and asks no policy provider (`cursorRecordsThisHook` in `cli/beacon-hooks/cmd/cursor_compat.go`), so each event is recorded once. The two pre-tool matchers differ (Claude's names Read, Grep and Glob; Cursor's names Shell and MCP), so a call only Claude's matcher selects, a subcommand Beacon's Cursor hooks don't run, or a machine without them at the user level still gets the Claude Code run's record and policy check.
+- Cursor hook telemetry for sessions, prompt submission, tool use, command execution, MCP-like tool activity, approval decisions, file edits, and agent reasoning (`afterAgentThought` thinking text recorded as `agent.reasoning` events in the OTel GenAI `gen_ai.output.messages` reasoning-part shape) where hook payloads expose those fields. The Cursor IDE also runs the hooks in the user-level `~/.claude/settings.json`, with Cursor payloads; when Beacon's own `~/.cursor/hooks.json` runs the same hook subcommand and that entry's matcher selects the call's tool, that Claude Code run writes nothing and asks no policy provider (`cursorRecordsThisHook` in `cli/beacon-hooks/cmd/cursor_compat.go`), so each event is recorded once. The two pre-tool matchers differ (Claude's names Read, Grep and Glob; Cursor's names Shell and MCP), so a call only Claude's matcher selects, a subcommand Beacon's Cursor hooks don't run, or a machine without them at the user level still gets the Claude Code run's record and policy check. While the desktop app shows a cloud agent it also runs the user-level hooks for that agent's `afterAgentThought`, `subagentStart` and `subagentStop` (nothing else; measured on Cursor 3.29 and 3.30); a Cursor payload whose conversation id starts with `bc-` (the cloud agent) or `task-call-` (its subagent) and that has no `workspace_roots` writes nothing outside a cloud sandbox (`cursorRelaysCloudAgent` in `cli/beacon-hooks/cmd/cursor_compat.go`), so a cloud agent never reads as a partial local session; the cloud agent's own project hooks from `beacon cloud cursor print-hooks` record it.
- Cline uses a Beacon-managed plugin (`~/.cline/plugins/beacon.ts`) for live capture plus `beacon endpoint cline sync` for local history backfill. Cline's own OTel export/hosted prompt storage are not used, and approvals are not exposed or synthesized.
- Pi-family runtimes use Beacon-managed extensions and the shared `cli/beacon-hooks/cmd/pi_family.go` mapper while keeping separate harness names and install roots: Pi (`pi_cli`), Oh My Pi (`omp`), Prime Agent (`prime_agent`), and Senpi/OMO (`omo_senpi`). Pi, Prime, and Senpi do not expose operator approval decisions, so Beacon does not synthesize them. Oh My Pi exposes real approval events and the extension carries the remembered tool input onto those approvals.
- Prime Agent is the Pi-family exception with a single persistent `ipython` tool: kernel cells are recorded as `command.executed`, carry Python status/output metadata, and have no invented exit code. MCP is not separately attributed because Prime exposes integrations inside the kernel. `beacon endpoint prime sync` is the local poll backfill from `~/.prime/agent/sessions` and session artifacts.
diff --git a/cli/beacon-hooks/cmd/cursor_compat.go b/cli/beacon-hooks/cmd/cursor_compat.go
index 5837bfe2..614897ce 100644
--- a/cli/beacon-hooks/cmd/cursor_compat.go
+++ b/cli/beacon-hooks/cmd/cursor_compat.go
@@ -70,6 +70,37 @@ func cursorRecordsThisHook(command string, input map[string]interface{}) bool {
return false
}
+// cursorRelaysCloudAgent reports whether this payload is the Cursor desktop app running a hook on
+// this machine for a cloud agent's event.
+//
+// A cloud agent runs in Cursor's VM, which loads only project, team and enterprise hooks. While the
+// desktop app's Agents Window shows one, it also runs the user-level hooks here, but only for
+// afterAgentThought, subagentStart and subagentStop (measured on Cursor 3.29 and 3.30): no session
+// start, prompt, tool call, response or stop. Recorded, those made a session of reasoning and
+// subagent summaries attributed to this machine, with nothing to say the agent never ran on it.
+//
+// Such a payload names the cloud agent ("bc-<uuid>") or one of its subagents ("task-call-<id>")
+// and no workspace. A cloud agent on a self-hosted worker has the same kind of id but runs in a
+// checkout, so a hook there keeps recording, as does every hook in a cloud sandbox
+// (BEACON_ORIGIN=cloud), where the project hooks from `beacon cloud cursor print-hooks` record
+// the agent itself.
+func cursorRelaysCloudAgent(input map[string]interface{}) bool {
+ if strings.TrimSpace(os.Getenv("BEACON_ORIGIN")) == "cloud" {
+ return false
+ }
+ id := getFirstStr(input, "conversation_id", "parent_conversation_id")
+ if !strings.HasPrefix(id, "bc-") && !strings.HasPrefix(id, "task-call-") {
+ return false
+ }
+ roots, _ := input["workspace_roots"].([]interface{})
+ for _, root := range roots {
+ if s, ok := root.(string); ok && strings.TrimSpace(s) != "" {
+ return false
+ }
+ }
+ return true
+}
+
// cursorMatcherSelects reports whether a Cursor hook entry's matcher selects tool. An entry with no
// matcher runs for every call. Cursor reads a matcher as a pattern found anywhere in the tool's
// name, which is how Beacon's "MCP" selects "MCP:slack_send_message". A matcher that isn't a valid
diff --git a/cli/beacon-hooks/cmd/cursor_compat_test.go b/cli/beacon-hooks/cmd/cursor_compat_test.go
index 653afd98..00ab5281 100644
--- a/cli/beacon-hooks/cmd/cursor_compat_test.go
+++ b/cli/beacon-hooks/cmd/cursor_compat_test.go
@@ -9,6 +9,8 @@ import (
"strings"
"testing"
+ "github.com/spf13/cobra"
+
"github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/logging"
)
@@ -320,3 +322,96 @@ func TestCursorRecordsThisHookToleratesBadFiles(t *testing.T) {
t.Fatal("an unknown command matched")
}
}
+
+// relayedCloudThought is an afterAgentThought payload as the Cursor desktop app sends it to the
+// user-level hooks while its Agents Window shows a cloud agent (captured on Cursor 3.30.8): the
+// cloud agent's id, no workspace and no transcript.
+func relayedCloudThought(conversationID string) map[string]interface{} {
+ return map[string]interface{}{
+ "conversation_id": conversationID,
+ "generation_id": "",
+ "hook_event_name": "afterAgentThought",
+ "text": "Exploring the repository layout first.",
+ "duration_ms": float64(1200),
+ "transcript_path": nil,
+ "workspace_roots": []interface{}{},
+ }
+}
+
+func relayedCloudSubagentStop() map[string]interface{} {
+ return map[string]interface{}{
+ "conversation_id": "bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81",
+ "parent_conversation_id": "bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81",
+ "generation_id": "",
+ "hook_event_name": "subagentStop",
+ "subagent_type": "explore",
+ "status": "completed",
+ "summary": "The repository is a Go module.",
+ "transcript_path": nil,
+ "workspace_roots": []interface{}{},
+ }
+}
+
+func TestCursorDesktopRelayOfACloudAgentRecordsNothing(t *testing.T) {
+ cases := []struct {
+ name string
+ declared string
+ command string
+ run func(cmd *cobra.Command, args []string)
+ payload map[string]interface{}
+ }{
+ {"the agent's reasoning", "cursor", "agent-thought", runAgentThought, relayedCloudThought("bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81")},
+ // A subagent's reasoning carries the subagent's own id, newline included, and no parent.
+ {"a subagent's reasoning", "cursor", "agent-thought", runAgentThought, relayedCloudThought("task-call-e65dd302-df4c-454d-b435-a575a7e1cef5-2\nfc_7ab70849-9c8e-9581-bea6-1a9338d8ee33_0")},
+ // Beacon's Cursor hooks run no subagent command, so this one arrives through the Claude Code
+ // hook Cursor also runs.
+ {"a subagent stopping, through the Claude Code hook", "claude", "subagent-stop", subagentStopCmd.Run, relayedCloudSubagentStop()},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ logPath := setupCursorCompatRun(t, tc.declared, tc.command)
+ runHookWithInput(t, tc.run, tc.payload)
+ if n := countEndpointEvents(t, logPath); n != 0 {
+ t.Fatalf("wrote %d events for a cloud agent that never ran here, want 0", n)
+ }
+ })
+ }
+}
+
+func TestCursorCloudAgentsStillRecordWhereTheyRun(t *testing.T) {
+ t.Run("in a cloud sandbox", func(t *testing.T) {
+ t.Setenv("BEACON_ORIGIN", "cloud")
+ logPath := setupCursorCompatRun(t, "cursor", "agent-thought")
+ runHookWithInput(t, runAgentThought, relayedCloudThought("bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81"))
+ if n := countEndpointEvents(t, logPath); n != 1 {
+ t.Fatalf("wrote %d events, want the reasoning recorded", n)
+ }
+ })
+ t.Run("on a self-hosted worker, in a checkout", func(t *testing.T) {
+ payload := relayedCloudThought("bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81")
+ payload["workspace_roots"] = []interface{}{"/home/worker/repo"}
+ logPath := setupCursorCompatRun(t, "cursor", "agent-thought")
+ runHookWithInput(t, runAgentThought, payload)
+ if n := countEndpointEvents(t, logPath); n != 1 {
+ t.Fatalf("wrote %d events, want the reasoning recorded", n)
+ }
+ })
+ t.Run("a local conversation with no workspace open", func(t *testing.T) {
+ // The Agents Window runs local agents too, and without a folder they have no roots either.
+ logPath := setupCursorCompatRun(t, "cursor", "agent-thought")
+ runHookWithInput(t, runAgentThought, relayedCloudThought("8b01d14e-50f0-41f8-aa3f-6781f51243d4"))
+ if n := countEndpointEvents(t, logPath); n != 1 {
+ t.Fatalf("wrote %d events, want the reasoning recorded", n)
+ }
+ })
+}
+
+func TestCursorDesktopRelayReplyIsUnchanged(t *testing.T) {
+ setupCursorCompatRun(t, "cursor", "agent-thought")
+ relayed := runHookWithInput(t, runAgentThought, relayedCloudThought("bc-9af6e247-b89f-4ae9-9743-d5d5de5b8f81"))
+ setupCursorCompatRun(t, "cursor", "agent-thought")
+ local := runHookWithInput(t, runAgentThought, relayedCloudThought("56b95d2b-bed7-4c60-9141-0b165f5dddbe"))
+ if !reflect.DeepEqual(relayed, local) {
+ t.Fatalf("relayed run replied %#v, want the local reply %#v", relayed, local)
+ }
+}
diff --git a/cli/beacon-hooks/cmd/helpers.go b/cli/beacon-hooks/cmd/helpers.go
index ca4a7711..e5c0d0c7 100644
--- a/cli/beacon-hooks/cmd/helpers.go
+++ b/cli/beacon-hooks/cmd/helpers.go
@@ -25,13 +25,15 @@ var duplicateCursorRun bool
func readStdinJSON() (map[string]interface{}, error) {
declaredPlatform = platformFlag
duplicateCursorRun = false
+ relayedCloudRun := false
var input map[string]interface{}
err := json.NewDecoder(os.Stdin).Decode(&input)
if err == nil {
applyPayloadPlatformOverride(input)
duplicateCursorRun = declaredPlatform == "claude" && platformFlag == "cursor" && cursorRecordsThisHook(hookCommand, input)
+ relayedCloudRun = platformFlag == "cursor" && cursorRelaysCloudAgent(input)
}
- logging.SuppressEndpointEvents(duplicateCursorRun)
+ logging.SuppressEndpointEvents(duplicateCursorRun || relayedCloudRun)
return input, err
}
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index 9e5af7e5..4f0a124c 100644
--- a/docs/changelog/cli.mdx
+++ b/docs/changelog/cli.mdx
@@ -13,6 +13,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.
Changes on `main` since v1.3.60. They ship in the next release.
+- **Cursor cloud agents no longer leave partial sessions on the endpoint** · While the Cursor desktop app shows a cloud agent, it runs the user-level hooks on your machine for that agent's reasoning and subagent events, but not for its prompts, tool calls, replies or turn ends, which run in Cursor's VM. Beacon recorded those calls as `agent.reasoning` and `subagent.stopped` events from the machine, so a cloud agent looked like a local Cursor session with only reasoning in it, and a subagent's reasoning formed a session of its own. A Cursor hook payload that names a cloud agent (`bc-…`) or one of its subagents (`task-call-…`) and no workspace now writes nothing outside a cloud sandbox. A cloud agent on a self-hosted worker, which runs in a checkout, is still recorded, and so is everything the [Cursor Cloud Agents](/runtimes/cursor-cloud-agents) project hooks capture in the VM.
- **Antigravity CLI records every prompt** · Antigravity has no prompt hook, so Beacon recovered only a session's first prompt, from its transcript on the first tool call: later prompts, and turns that ran no tool, were never recorded. The managed hook block now also runs `beacon-hooks` on `PreInvocation`, which Antigravity calls before every model call with the turn's prompt as `lastUserInput`, and Beacon records it on the first call of each turn (`invocationNum` 0), resumed conversations included. Package repair adds the handler to installed user-level hooks; for project-level or manual installs, rerun `beacon endpoint hooks install --harness antigravity` at the same level.
- **Antigravity CLI session sync** · `beacon endpoint antigravity sync|status` (alias `antigravity-cli`) reads the conversations Antigravity keeps under `~/.gemini/antigravity-cli/brain` and records them as `harness.collection_method=poll` events: prompts, agent messages, reasoning, tool calls, commands with exit code and output, file reads and edits, and per-response token usage, with the working directory from `conversation_summaries.db`. The install-time backfill and the scheduled session sync include it, so conversations from before the hooks worked are recorded. For a conversation the hooks already recorded, sync adds only agent messages, reasoning, and token usage from the point the hooks started, plus any prompt the hooks did not record, matched by content hash, such as the later prompts of a conversation recorded by v1.3.60 hooks. `beacon token-usage --coverage` now expects Antigravity usage from the sync instead of reporting it as not instrumented.
- **Antigravity CLI file edits are recorded as edits** · Antigravity edits files with `replace_file_content` and `multi_replace_file_content`, whose names the hook adapter's edit rule did not match, so a live edit was recorded as a plain `tool.invoked`; and its write and replace tools name their file `TargetFile`, which the adapter did not read, so even `write_to_file` carried no path. All three are now `file.modified` with the file's path. The hook adapter and `beacon endpoint antigravity sync` classify Antigravity tools from one table, so a call reads the same on either path.
diff --git a/docs/runtimes/cursor-cloud-agents.mdx b/docs/runtimes/cursor-cloud-agents.mdx
index 093703d6..762814c4 100644
--- a/docs/runtimes/cursor-cloud-agents.mdx
+++ b/docs/runtimes/cursor-cloud-agents.mdx
@@ -60,6 +60,21 @@ Beacon uses Cursor's `conversation_id` hook field as the default `run_id` for
Cursor Cloud telemetry. If you set `BEACON_RUN_ID` yourself, Beacon preserves
that value instead.
+### Cloud agents started from Cursor desktop
+
+A cloud agent runs in Cursor's VM whether you start it from the web, Slack, the
+API, or the Cursor desktop app with **Cloud** selected. Only this setup records
+what it does.
+
+If your machine also runs a local Beacon endpoint, the desktop app runs the
+hooks installed there for a cloud agent it shows, but only for the agent's
+reasoning and subagent events. Beacon does not record those calls on the
+endpoint, so a cloud agent does not show up as a partial local session. Beacon
+`v1.3.60` and earlier recorded them as `agent.reasoning` and `subagent.stopped`
+events from your machine, under session ids that start with `bc-` (the cloud
+agent) or `task-call-` (one of its subagents). Exclude those session ids when
+you read older endpoint data.
+
## Prerequisites
- Beacon CLI `v1.0.3` or later for direct S3 upload. Cursor Cloud prompt capture
diff --git a/docs/runtimes/cursor.mdx b/docs/runtimes/cursor.mdx
index 70563adf..352ae2c1 100644
--- a/docs/runtimes/cursor.mdx
+++ b/docs/runtimes/cursor.mdx
@@ -9,6 +9,15 @@ Beacon supports Cursor through native hook payloads sent to `beacon-hooks`, with
For provider-managed Cursor cloud sessions, see
[Cursor Cloud Agents](/runtimes/cursor-cloud-agents).
+While the Cursor desktop app shows a cloud agent, it also runs the hooks
+installed on your machine for that agent's reasoning and subagent events, but
+not for its prompts, tool calls, replies or turn ends, which happen in Cursor's
+VM. Beacon does not record those calls on the endpoint, so a cloud agent never
+appears as a partial local session. To record cloud agents, set up
+[Cursor Cloud Agents](/runtimes/cursor-cloud-agents). Beacon v1.3.60 and earlier
+recorded them as `agent.reasoning` and `subagent.stopped` events from your
+machine, under session ids that start with `bc-` or `task-call-`.
+
## Prerequisites
Before enabling Cursor hooks, make sure: