Skip to content

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

refactor(claude): let the model-context flag follow the latest install like every other option

Kyle Elliott1ae777a4e563
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index 52f97d38..10de6f05 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
- "strconv"
"strings"
"time"
@@ -32,7 +31,7 @@ var endpointOpts struct {
collectorPath string
includeRuntimeMetrics bool
includeCodexSpans bool
- claudeCaptureModelContext optionalBool
+ claudeCaptureModelContext bool
keepLogs bool
keepConfig bool
noStart bool
@@ -92,38 +91,7 @@ var endpointOpts struct {
}
const claudeCaptureModelContextUsage = "Record context Claude Code gives the model that no other event reports, such as the pages its WebFetch tool fetches. " +
- "Turns on Claude Code's API body logs; the collector keeps only that context and drops every body. " +
- "Kept until an install or repair passes --claude-capture-model-context=false"
-
-// optionalBool is a boolean flag that also records whether it was given, for an opt-in that an
-// install or repair without the flag must leave as it was.
-type optionalBool struct {
- value *bool
-}
-
-func (b *optionalBool) Set(s string) error {
- v, err := strconv.ParseBool(s)
- if err != nil {
- return err
- }
- b.value = &v
- return nil
-}
-
-func (b *optionalBool) String() string {
- if b == nil || b.value == nil {
- return "unset"
- }
- return strconv.FormatBool(*b.value)
-}
-
-func (b *optionalBool) Type() string { return "bool" }
-
-// registerOptionalBool registers b so that the bare flag means true and --flag=false means false.
-func registerOptionalBool(cmd *cobra.Command, b *optionalBool, name, usage string) {
- cmd.Flags().Var(b, name, usage)
- cmd.Flags().Lookup(name).NoOptDefVal = "true"
-}
+ "Turns on Claude Code's API body logs; the collector keeps only that context and drops every body"
var endpointCmd = &cobra.Command{
Use: "endpoint",
@@ -461,7 +429,7 @@ func init() {
endpointInstallCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and harness operational metrics (OpenClaw, Copilot CLI) in the runtime JSONL log")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.includeCodexSpans, "include-codex-spans", false, "Include high-volume Codex OTLP spans for troubleshooting")
- registerOptionalBool(endpointInstallCmd, &endpointOpts.claudeCaptureModelContext, "claude-capture-model-context", claudeCaptureModelContextUsage)
+ endpointInstallCmd.Flags().BoolVar(&endpointOpts.claudeCaptureModelContext, "claude-capture-model-context", false, claudeCaptureModelContextUsage)
endpointInstallCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the collector service")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.noBrowser, "no-browser", false, "During interactive setup, print the sign-in URL instead of opening a browser")
endpointInstallCmd.Flags().StringVar(&endpointOpts.serviceKind, "service", "", "Service manager to use: auto (default), launchd, systemd, or none for a supervised collector process")
@@ -485,7 +453,7 @@ func init() {
endpointRepairCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and harness operational metrics (OpenClaw, Copilot CLI) in the runtime JSONL log")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.includeCodexSpans, "include-codex-spans", false, "Include high-volume Codex OTLP spans for troubleshooting")
- registerOptionalBool(endpointRepairCmd, &endpointOpts.claudeCaptureModelContext, "claude-capture-model-context", claudeCaptureModelContextUsage)
+ endpointRepairCmd.Flags().BoolVar(&endpointOpts.claudeCaptureModelContext, "claude-capture-model-context", false, claudeCaptureModelContextUsage)
endpointRepairCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the collector service")
endpointRepairCmd.Flags().StringVar(&endpointOpts.serviceKind, "service", "", "Service manager to use: auto (default), launchd, systemd, or none for a supervised collector process")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.dryRun, "dry-run", false, "Print planned actions without changing endpoint files or services")
diff --git a/cli/beacon/cmd/endpoint_install.go b/cli/beacon/cmd/endpoint_install.go
index fc6d5b22..49402742 100644
--- a/cli/beacon/cmd/endpoint_install.go
+++ b/cli/beacon/cmd/endpoint_install.go
@@ -126,7 +126,7 @@ func endpointInstallOptions(selection endpointTargetSelection, serviceKind servi
StartService: !endpointOpts.noStart,
IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,
IncludeCodexSpans: endpointOpts.includeCodexSpans,
- ClaudeCaptureModelContext: endpointOpts.claudeCaptureModelContext.value,
+ ClaudeCaptureModelContext: endpointOpts.claudeCaptureModelContext,
SplunkHEC: splunkHECOptions(),
FalconHEC: falconHECOptions(),
ServiceKind: serviceKind,
diff --git a/cli/beacon/cmd/endpoint_install_harness_test.go b/cli/beacon/cmd/endpoint_install_harness_test.go
index 5a75559b..6dd2d780 100644
--- a/cli/beacon/cmd/endpoint_install_harness_test.go
+++ b/cli/beacon/cmd/endpoint_install_harness_test.go
@@ -97,60 +97,22 @@ func TestEndpointRepairHookOnlyHarnessConfiguresNoOTLPRuntime(t *testing.T) {
assertNoOTLPHarnesses(t, "repair --harness omp", opts.Harnesses)
}
-// Model-context capture has Claude Code export every API body, so it changes only when the flag says
-// so: without it the lifecycle is told nothing and keeps the endpoint's recorded choice, which is
-// what the package upgrades and MDM repairs that re-run install rely on.
-func TestEndpointInstallAndRepairPassTheModelContextChoiceOnlyWhenGiven(t *testing.T) {
+// Model-context capture has Claude Code export every API body, so it stays off unless the flag asks for
+// it, and repair takes it from its own flags like install, so a repair without it turns it off.
+func TestEndpointInstallAndRepairCaptureClaudeWebFetchOnlyWhenAsked(t *testing.T) {
for _, repair := range []bool{false, true} {
- for _, tc := range []struct {
- flag string
- want *bool
- }{
- {"", nil},
- {"true", ptrTo(true)},
- {"false", ptrTo(false)},
- } {
- // The first recorded run restores every endpoint option when the test ends.
- endpointOpts.claudeCaptureModelContext = optionalBool{}
- if tc.flag != "" {
- if err := endpointOpts.claudeCaptureModelContext.Set(tc.flag); err != nil {
- t.Fatal(err)
- }
- }
- got := runRecordedEndpointCommand(t, repair, "claude").ClaudeCaptureModelContext
- if (got == nil) != (tc.want == nil) || (got != nil && *got != *tc.want) {
- t.Fatalf("repair=%t flag=%q: lifecycle got %v, want %v", repair, tc.flag, got, tc.want)
- }
+ // The first recorded run restores every endpoint option when the test ends.
+ endpointOpts.claudeCaptureModelContext = false
+ if opts := runRecordedEndpointCommand(t, repair, "claude"); opts.ClaudeCaptureModelContext {
+ t.Fatalf("repair=%t: Model-context capture is on without --claude-capture-model-context", repair)
}
- }
-}
-
-// The bare flag opts in and --claude-capture-model-context=false opts out, on install and repair.
-func TestClaudeCaptureModelContextFlagParses(t *testing.T) {
- for _, tc := range []struct {
- args []string
- want string
- }{
- {nil, "unset"},
- {[]string{"--claude-capture-model-context"}, "true"},
- {[]string{"--claude-capture-model-context=false"}, "false"},
- {[]string{"--claude-capture-model-context=true"}, "true"},
- } {
- var value optionalBool
- cmd := &cobra.Command{Use: "install", RunE: func(*cobra.Command, []string) error { return nil }}
- registerOptionalBool(cmd, &value, "claude-capture-model-context", "")
- cmd.SetArgs(tc.args)
- if err := cmd.Execute(); err != nil {
- t.Fatalf("%v: %v", tc.args, err)
- }
- if got := value.String(); got != tc.want {
- t.Fatalf("%v parsed to %s, want %s", tc.args, got, tc.want)
+ endpointOpts.claudeCaptureModelContext = true
+ if opts := runRecordedEndpointCommand(t, repair, "claude"); !opts.ClaudeCaptureModelContext {
+ t.Fatalf("repair=%t: --claude-capture-model-context did not reach the lifecycle", repair)
}
}
}
-func ptrTo[T any](v T) *T { return &v }
-
// `--harness ""` is the documented collector-only install (splitHarnessCSV keeps it an empty
// list on purpose), so it must configure no runtime at all.
func TestEndpointInstallCollectorOnlyHarnessConfiguresNoOTLPRuntime(t *testing.T) {
diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.go
index 62d8dee3..05e52654 100644
--- a/cli/beacon/internal/endpoint/harness/harness.go
+++ b/cli/beacon/internal/endpoint/harness/harness.go
@@ -8,7 +8,6 @@ import (
"os/exec"
"path/filepath"
"runtime"
- "sort"
"strings"
"time"
@@ -390,7 +389,18 @@ func ConfigureClaude(opts ConfigureOptions) (string, error) {
// identity/arguments needed to reconstruct agent activity from OTel events.
env["OTEL_LOG_TOOL_DETAILS"] = "1"
env["OTEL_LOG_USER_PROMPTS"] = "1"
- configureClaudeModelContext(env, opts.CaptureModelContext)
+ // Inline API bodies carry the page WebFetch sends to its summarizer model, the
+ // only place Claude Code reports it, and also the system prompt and the whole
+ // conversation. The collector's claude_api_body processor keeps only that context,
+ // but Claude Code is asked for them only on opt-in. Neither branch overrides 0 or
+ // file:<dir>; without the opt-in an inline value goes, so opting out works.
+ rawBodies, configured := env["OTEL_LOG_RAW_API_BODIES"]
+ switch {
+ case opts.CaptureModelContext && !configured:
+ env["OTEL_LOG_RAW_API_BODIES"] = "1"
+ case !opts.CaptureModelContext && claudeInlineRawBodies(rawBodies):
+ delete(env, "OTEL_LOG_RAW_API_BODIES")
+ }
settings["env"] = env
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return "", err
@@ -792,55 +802,14 @@ func commandVersion(path string) string {
return strings.TrimSpace(string(out))
}
-// claudeModelContextMarker names, in Claude Code's own env block, the settings Beacon wrote for
-// --claude-capture-model-context. Install and repair without the opt-in remove those and nothing
-// else: a value the user set themselves is theirs, and the collector keeps nothing from the bodies
-// it produces unless the endpoint was installed with the opt-in. Claude Code ignores the key.
-const claudeModelContextMarker = "BEACON_CLAUDE_MODEL_CONTEXT"
-
-// claudeModelContextValues are the values Beacon writes for --claude-capture-model-context.
-var claudeModelContextValues = map[string]string{
- "OTEL_LOG_RAW_API_BODIES": "1",
-}
-
-// configureClaudeModelContext sets or removes Beacon's model-context settings in Claude Code's env.
-//
-// Inline API bodies carry the page WebFetch sends to its summarizer model, the only place Claude
-// Code reports it, and also the system prompt and the whole conversation. The collector's
-// claude_api_body processor keeps only that context, and only on the opt-in, but Claude Code is
-// asked for the bodies only on the opt-in too. The opt-in sets a setting only where none is set, so
-// 0, file:<dir> and a user's own 1 are never taken over; without it, a setting Beacon wrote goes
-// unless it has been changed since.
-func configureClaudeModelContext(env map[string]interface{}, capture bool) {
- owned := map[string]bool{}
- for _, key := range strings.Split(fmt.Sprint(env[claudeModelContextMarker]), ",") {
- if _, known := claudeModelContextValues[key]; known {
- owned[key] = true
- }
- }
- if capture {
- if _, set := env["OTEL_LOG_RAW_API_BODIES"]; !set {
- env["OTEL_LOG_RAW_API_BODIES"] = claudeModelContextValues["OTEL_LOG_RAW_API_BODIES"]
- owned["OTEL_LOG_RAW_API_BODIES"] = true
- }
- } else {
- for key := range owned {
- if fmt.Sprint(env[key]) == claudeModelContextValues[key] {
- delete(env, key)
- }
- }
- owned = nil
+// claudeInlineRawBodies reports whether an OTEL_LOG_RAW_API_BODIES value has Claude Code put
+// API bodies inline in its log events, rather than leave them off or write them to files.
+func claudeInlineRawBodies(value interface{}) bool {
+ switch strings.ToLower(strings.TrimSpace(fmt.Sprint(value))) {
+ case "1", "true":
+ return true
}
- var keys []string
- for key := range owned {
- keys = append(keys, key)
- }
- if len(keys) == 0 {
- delete(env, claudeModelContextMarker)
- return
- }
- sort.Strings(keys)
- env[claudeModelContextMarker] = strings.Join(keys, ",")
+ return false
}
func backup(path string, data []byte) error {
diff --git a/cli/beacon/internal/endpoint/harness/harness_test.go b/cli/beacon/internal/endpoint/harness/harness_test.go
index 64d1fa7c..ec040d05 100644
--- a/cli/beacon/internal/endpoint/harness/harness_test.go
+++ b/cli/beacon/internal/endpoint/harness/harness_test.go
@@ -125,29 +125,26 @@ func TestConfigureClaudeEnablesPromptLogging(t *testing.T) {
}
// Model-context capture is opt-in. The opt-in sets inline API bodies only where nothing is set, and
-// install without it removes only a setting Beacon wrote, so a repair without the flag turns
-// Beacon's capture off and leaves a user's own setting alone. Neither overrides 0 or file:<dir>.
-func TestConfigureClaudeRawBodiesFollowTheModelContextOptIn(t *testing.T) {
+// install without it removes an inline setting, so a repair without the flag turns capture off.
+// Neither overrides 0 or file:<dir>.
+func TestConfigureClaudeRawBodiesFollowTheWebFetchOptIn(t *testing.T) {
const unset = "<unset>"
tests := []struct {
- steps []bool
+ capture bool
before, want string
}{
- {steps: []bool{true}, before: unset, want: "1"},
- {steps: []bool{true}, before: "1", want: "1"},
- {steps: []bool{true}, before: "0", want: "0"},
- {steps: []bool{true}, before: "file:/private/claude-bodies", want: "file:/private/claude-bodies"},
- {steps: []bool{false}, before: unset, want: unset},
- {steps: []bool{false}, before: "1", want: "1"},
- {steps: []bool{false}, before: "true", want: "true"},
- {steps: []bool{false}, before: "0", want: "0"},
- {steps: []bool{false}, before: "file:/private/claude-bodies", want: "file:/private/claude-bodies"},
- {steps: []bool{true, false}, before: unset, want: unset},
- {steps: []bool{true, true, false}, before: unset, want: unset},
- {steps: []bool{true, false}, before: "1", want: "1"},
+ {capture: true, before: unset, want: "1"},
+ {capture: true, before: "1", want: "1"},
+ {capture: true, before: "0", want: "0"},
+ {capture: true, before: "file:/private/claude-bodies", want: "file:/private/claude-bodies"},
+ {capture: false, before: unset, want: unset},
+ {capture: false, before: "1", want: unset},
+ {capture: false, before: "true", want: unset},
+ {capture: false, before: "0", want: "0"},
+ {capture: false, before: "file:/private/claude-bodies", want: "file:/private/claude-bodies"},
}
for _, tc := range tests {
- t.Run(fmt.Sprintf("%v/%s", tc.steps, tc.before), func(t *testing.T) {
+ t.Run(fmt.Sprintf("capture=%t/%s", tc.capture, tc.before), func(t *testing.T) {
home := t.TempDir()
testenv.SetHome(t, home)
path := filepath.Join(home, ".claude", "settings.json")
@@ -165,8 +162,8 @@ func TestConfigureClaudeRawBodiesFollowTheModelContextOptIn(t *testing.T) {
if err := os.WriteFile(path, before, 0600); err != nil {
t.Fatal(err)
}
- for _, capture := range tc.steps {
- if _, err := ConfigureClaude(ConfigureOptions{Endpoint: "http://127.0.0.1:4317", CaptureModelContext: capture}); err != nil {
+ for range 2 {
+ if _, err := ConfigureClaude(ConfigureOptions{Endpoint: "http://127.0.0.1:4317", CaptureModelContext: tc.capture}); err != nil {
t.Fatal(err)
}
}
@@ -183,10 +180,7 @@ func TestConfigureClaudeRawBodiesFollowTheModelContextOptIn(t *testing.T) {
got = unset
}
if got != tc.want {
- t.Fatalf("OTEL_LOG_RAW_API_BODIES after installs %v = %q, want %q", tc.steps, got, tc.want)
- }
- if marker, set := settings["env"][claudeModelContextMarker]; set && !tc.steps[len(tc.steps)-1] {
- t.Fatalf("%s = %q left behind after an install without the opt-in", claudeModelContextMarker, marker)
+ t.Fatalf("OTEL_LOG_RAW_API_BODIES after install and reinstall = %q, want %q", got, tc.want)
}
})
}
diff --git a/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go b/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go
index cb3c2aed..9a202d12 100644
--- a/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/harness_selection_test.go
@@ -93,11 +93,9 @@ func TestRepairWithExplicitEmptyHarnessesLeavesClaudeAndCodexConfigAlone(t *test
}
}
-// Model-context capture is on after an install with the flag, stays on through a repair that does
-// not mention it -- the package upgrades, MDM repairs and self-updates that re-run install -- and is
-// off after a repair that turns it off, in Claude Code's settings, config.json and the collector
-// config alike.
-func TestClaudeModelContextCaptureFollowsTheLastInstallThatChoseIt(t *testing.T) {
+// Model-context capture follows the flag of the install or repair that ran last: on with it, off again
+// after a repair without it, in Claude Code's settings, config.json and the collector config alike.
+func TestClaudeWebFetchCaptureFollowsTheLatestInstallOrRepair(t *testing.T) {
testenv.RequirePOSIXExecutableFixtures(t)
home := t.TempDir()
testenv.SetHome(t, home)
@@ -147,9 +145,8 @@ func TestClaudeModelContextCaptureFollowsTheLastInstallThatChoseIt(t *testing.T)
}
return cfg.ClaudeCaptureModelContext
}
- on, off := true, false
- opts.ClaudeCaptureModelContext = &on
+ opts.ClaudeCaptureModelContext = true
if _, err := Install(opts); err != nil {
t.Fatalf("Install: %v", err)
}
@@ -157,19 +154,11 @@ func TestClaudeModelContextCaptureFollowsTheLastInstallThatChoseIt(t *testing.T)
t.Fatalf("after install with the flag: OTEL_LOG_RAW_API_BODIES = %q, recorded = %t; want 1 and true", value, recorded())
}
- opts.ClaudeCaptureModelContext = nil
- if _, err := Repair(opts); err != nil {
- t.Fatalf("Repair: %v", err)
- }
- if value, _ := rawBodies(); value != "1" || !recorded() {
- t.Fatalf("after repair without the flag: OTEL_LOG_RAW_API_BODIES = %q, recorded = %t; want capture still on", value, recorded())
- }
-
- opts.ClaudeCaptureModelContext = &off
+ opts.ClaudeCaptureModelContext = false
if _, err := Repair(opts); err != nil {
t.Fatalf("Repair: %v", err)
}
if value, set := rawBodies(); set || recorded() {
- t.Fatalf("after repair with the flag false: OTEL_LOG_RAW_API_BODIES = %q (set %t), recorded = %t; want capture off", value, set, recorded())
+ t.Fatalf("after repair without the flag: OTEL_LOG_RAW_API_BODIES = %q (set %t), recorded = %t; want capture off", value, set, recorded())
}
}
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
index 08588a12..9d166168 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
@@ -193,15 +193,12 @@ type InstallOptions struct {
HTTPPort int
// HealthPort is the collector health_check port. Zero derives it from the OTLP ports
// (endpointconfig.DeriveHealthCheckPort), which keeps 13133 for the default ports.
- HealthPort int
- CollectorPath string
- StartService bool
- IncludeRuntimeMetrics bool
- IncludeCodexSpans bool
- // ClaudeCaptureModelContext is --claude-capture-model-context. nil keeps the choice the
- // endpoint's config.json records, so an install or repair that does not pass the flag neither
- // opts in nor out.
- ClaudeCaptureModelContext *bool
+ HealthPort int
+ CollectorPath string
+ StartService bool
+ IncludeRuntimeMetrics bool
+ IncludeCodexSpans bool
+ ClaudeCaptureModelContext bool
SplunkHEC *endpointconfig.SplunkHEC
FalconHEC *endpointconfig.FalconHEC
// ServiceKind selects the service manager. Empty auto-detects: launchd on macOS,
@@ -717,14 +714,6 @@ func Repair(opts InstallOptions) (InstallResult, error) {
priorAutoUpdateMode = mode
}
}
- // The uninstall below removes config.json with the rest of the manifest, so a choice the repair
- // does not make is read before it goes.
- if opts.ClaudeCaptureModelContext == nil {
- if prior, err := endpointconfig.Load(opts.UserMode); err == nil {
- capture := prior.ClaudeCaptureModelContext
- opts.ClaudeCaptureModelContext = &capture
- }
- }
_ = Uninstall(repairUninstallOptions(opts))
result, err := Install(opts)
if err != nil {
@@ -902,8 +891,6 @@ func buildConfig(opts InstallOptions) endpointconfig.Config {
// managed_ingest block is owned by connect/disconnect, so carry the existing one over.
// The same goes for inventory_heartbeat: an operator's `enabled: false` must survive the
// package upgrade that re-runs install, or the scheduled job would come back.
- // And the model-context opt-in, unless this install says otherwise: packages, MDM repairs and
- // self-update all re-run install without the flag, and must not opt the endpoint out.
if existing, err := endpointconfig.Load(opts.UserMode); err == nil {
if existing.ManagedIngest != nil {
cfg.ManagedIngest = existing.ManagedIngest
@@ -911,7 +898,6 @@ func buildConfig(opts InstallOptions) endpointconfig.Config {
if existing.Inventory != nil {
cfg.Inventory = existing.Inventory
}
- cfg.ClaudeCaptureModelContext = existing.ClaudeCaptureModelContext
}
if opts.Harnesses != nil {
cfg.Harnesses = opts.Harnesses
@@ -933,9 +919,7 @@ func buildConfig(opts InstallOptions) endpointconfig.Config {
cfg.Collector.BinaryPath = opts.CollectorPath
cfg.Collector.IncludeRuntimeMetrics = opts.IncludeRuntimeMetrics
cfg.Collector.IncludeCodexSpans = opts.IncludeCodexSpans
- if opts.ClaudeCaptureModelContext != nil {
- cfg.ClaudeCaptureModelContext = *opts.ClaudeCaptureModelContext
- }
+ cfg.ClaudeCaptureModelContext = opts.ClaudeCaptureModelContext
if opts.SplunkHEC != nil {
if cfg.Destinations == nil {
cfg.Destinations = &endpointconfig.Destinations{}
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index 6f9efa5d..c577086d 100644
--- a/docs/changelog/cli.mdx
+++ b/docs/changelog/cli.mdx
@@ -16,11 +16,10 @@ Stay up to date with the latest changes to the Agent Beacon CLI.
Code's API-body logs, so Beacon can record context Claude Code gives the model
that no other event reports. The first is the page WebFetch hands its summarizer
model, recorded as a `WebFetch` tool result, which `indirect-injection-in-tool-result`
- evaluates. The choice is kept by later installs, repairs, and package upgrades
- that do not pass the flag; `--claude-capture-model-context=false` turns it off,
- and `BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT` sets it from packages and MDM. Install
- changes only the Claude Code settings it wrote, never one you set yourself. A CI
- job opts in by setting `OTEL_LOG_RAW_API_BODIES=1` in its environment.
+ evaluates. Without the flag, install and repair remove an inline
+ `OTEL_LOG_RAW_API_BODIES` (`1` or `true`) from `~/.claude/settings.json`; `0`
+ and `file:<dir>` are left alone. A CI job opts in by setting
+ `OTEL_LOG_RAW_API_BODIES=1` in its environment.
- **API bodies are filtered before every destination** · A new collector
processor, `claude_api_body`, runs ahead of every exporter, Splunk HEC included.
It drops every Claude Code API body, and with the opt-in keeps only the WebFetch
diff --git a/docs/cli/endpoint-install.mdx b/docs/cli/endpoint-install.mdx
index dde80732..daa7235e 100644
--- a/docs/cli/endpoint-install.mdx
+++ b/docs/cli/endpoint-install.mdx
@@ -37,7 +37,7 @@ The `claude` harness writes both Claude Code's OpenTelemetry settings and its us
| `--dry-run` | Print planned actions without changing endpoint files or services |
| `--include-runtime-metrics` | Include generic process, runtime, and harness operational OTLP metrics in Beacon JSONL. By default, low-signal metrics such as process CPU, memory, Node.js event loop, V8 heap, GitHub Copilot CLI, and OpenClaw operational metrics are filtered out |
| `--include-codex-spans` | Include every high-volume Codex OTLP span for troubleshooting. By default, Beacon keeps semantic logs and only the usage-bearing completed turn span |
-| `--claude-capture-model-context` | Record context Claude Code gives the model that no other event reports, such as the pages its WebFetch tool fetches. Turns on Claude Code's API-body logs; the collector keeps only that context and drops every body. Off by default. The choice is kept by later installs that do not pass the flag; `--claude-capture-model-context=false` turns it off, and `BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT=1` or `0` does the same for package and MDM installs. See [Claude Code: model context from API bodies](/runtimes/claude-code#model-context-from-api-bodies) |
+| `--claude-capture-model-context` | Record context Claude Code gives the model that no other event reports, such as the pages its WebFetch tool fetches. Turns on Claude Code's API-body logs; the collector keeps only that context and drops every body. Off by default; an install without the flag turns it off. See [Claude Code: model context from API bodies](/runtimes/claude-code#model-context-from-api-bodies) |
| `--splunk-hec-endpoint <url>` | Splunk HEC endpoint URL |
| `--splunk-hec-token <token>` | Splunk HEC token |
| `--splunk-index <index>` | Optional Splunk index |
diff --git a/docs/cli/endpoint-repair.mdx b/docs/cli/endpoint-repair.mdx
index 16fba260..f73a196e 100644
--- a/docs/cli/endpoint-repair.mdx
+++ b/docs/cli/endpoint-repair.mdx
@@ -32,7 +32,7 @@ During repair, Beacon removes the existing managed service before reinstalling i
| `--dry-run` | Print planned actions without changing endpoint files or services |
| `--include-runtime-metrics` | Include generic process, runtime, and harness operational OTLP metrics in Beacon JSONL. By default, low-signal metrics such as process CPU, memory, Node.js event loop, V8 heap, GitHub Copilot CLI, and OpenClaw operational metrics are filtered out |
| `--include-codex-spans` | Include every high-volume Codex OTLP span for troubleshooting. By default, Beacon keeps semantic logs and only the usage-bearing completed turn span |
-| `--claude-capture-model-context` | Record context Claude Code gives the model that no other event reports, such as the pages its WebFetch tool fetches. A repair without the flag keeps the endpoint's current choice; `--claude-capture-model-context=false` turns capture off. See [Claude Code: model context from API bodies](/runtimes/claude-code#model-context-from-api-bodies) |
+| `--claude-capture-model-context` | Record context Claude Code gives the model that no other event reports, such as the pages its WebFetch tool fetches. Pass it on every repair that should keep capture on; a repair without it turns capture off. See [Claude Code: model context from API bodies](/runtimes/claude-code#model-context-from-api-bodies) |
| `--splunk-hec-endpoint <url>` | Splunk HEC endpoint URL |
| `--splunk-hec-token <token>` | Splunk HEC token |
| `--splunk-index <index>` | Optional Splunk index |
diff --git a/docs/runtimes/claude-code.mdx b/docs/runtimes/claude-code.mdx
index 184613cd..10647d6a 100644
--- a/docs/runtimes/claude-code.mdx
+++ b/docs/runtimes/claude-code.mdx
@@ -78,9 +78,7 @@ Some of what Claude Code gives the model appears in no OTLP event except its API
beacon endpoint install --claude-capture-model-context
```
-The choice is recorded as `claude_capture_model_context` in Beacon's `config.json` and kept until an install or repair changes it, so package upgrades, MDM repairs, and self-updates that re-run install without the flag leave it as it was. To turn capture off, pass `--claude-capture-model-context=false`. A package or MDM install can set `BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT=1` or `0` instead of the flag.
-
-With capture on, install sets `OTEL_LOG_RAW_API_BODIES=1` in `~/.claude/settings.json` if it is unset, and marks the settings it wrote in `BEACON_CLAUDE_MODEL_CONTEXT` in the same `env` block. With capture off, install removes only what that marker names. A value you set yourself, including `0`, `1`, and `file:<dir>` (bodies written to files), is never changed. `beacon ci exec` does not set the variable; a CI job opts in by setting `OTEL_LOG_RAW_API_BODIES=1` (or `true`) in its own environment, and the job's collector then keeps the same context an opted-in endpoint does.
+With the flag, install and repair set `OTEL_LOG_RAW_API_BODIES=1` in `~/.claude/settings.json`, and the choice is recorded as `claude_capture_model_context` in Beacon's `config.json`. Without it, they remove an inline setting (`1` or `true`), so a repair without the flag turns capture off. Neither touches `0` (off) or `file:<dir>` (bodies written to files). `beacon ci exec` does not set the variable; a CI job opts in by setting `OTEL_LOG_RAW_API_BODIES=1` (or `true`) in its own environment, and the job's collector then keeps the same context an opted-in endpoint does.
Whatever turned the bodies on, the collector filters them in its `claude_api_body` processor. The processor runs before every destination, including the local runtime log, Falcon, and Splunk HEC. With capture on, it keeps only the context listed below. With capture off, it drops every body, so turning `OTEL_LOG_RAW_API_BODIES` on yourself sends Beacon nothing it keeps. The `claude_code.api_request` event already records each model call.
diff --git a/packaging/linux/install-endpoint.sh b/packaging/linux/install-endpoint.sh
index d5df16d7..63c1a705 100755
--- a/packaging/linux/install-endpoint.sh
+++ b/packaging/linux/install-endpoint.sh
@@ -52,10 +52,4 @@ set -- endpoint install --system \
[ "$BEACON_SPLUNK_INSECURE_SKIP_VERIFY" = "1" ] && set -- "$@" --splunk-insecure-skip-verify
[ -n "$BEACON_SPLUNK_CA_FILE" ] && set -- "$@" --splunk-ca-file "$BEACON_SPLUNK_CA_FILE"
-# Unset leaves the endpoint's recorded choice alone, so a package upgrade neither opts in nor out.
-case "${BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT:-}" in
- 1|true|TRUE|yes|YES) set -- "$@" --claude-capture-model-context ;;
- 0|false|FALSE|no|NO) set -- "$@" --claude-capture-model-context=false ;;
-esac
-
exec "$BEACON_BIN" "$@"
diff --git a/packaging/macos/fleet/scripts/repair.sh b/packaging/macos/fleet/scripts/repair.sh
index cbbf5846..d081c83b 100755
--- a/packaging/macos/fleet/scripts/repair.sh
+++ b/packaging/macos/fleet/scripts/repair.sh
@@ -74,14 +74,5 @@ esac
if [ -n "$BEACON_FALCON_CA_FILE" ]; then
set -- "$@" --falcon-ca-file "$BEACON_FALCON_CA_FILE"
fi
-# Unset leaves the endpoint's recorded choice alone, so a repair neither opts in nor out.
-case "${BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT:-}" in
- 1|true|TRUE|yes|YES)
- set -- "$@" --claude-capture-model-context
- ;;
- 0|false|FALSE|no|NO)
- set -- "$@" --claude-capture-model-context=false
- ;;
-esac
exec "$BEACON_BIN" "$@"
diff --git a/packaging/macos/install-endpoint.sh b/packaging/macos/install-endpoint.sh
index 80d79200..ef50be6d 100755
--- a/packaging/macos/install-endpoint.sh
+++ b/packaging/macos/install-endpoint.sh
@@ -97,15 +97,5 @@ case "$BEACON_NO_START" in
;;
esac
-# Unset leaves the endpoint's recorded choice alone, so a package upgrade neither opts in nor out.
-case "${BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT:-}" in
- 1|true|TRUE|yes|YES)
- set -- "$@" --claude-capture-model-context
- ;;
- 0|false|FALSE|no|NO)
- set -- "$@" --claude-capture-model-context=false
- ;;
-esac
-
exec "$BEACON_BIN" "$@"
diff --git a/packaging/macos/jamf/scripts/repair.sh b/packaging/macos/jamf/scripts/repair.sh
index 4542571d..fc078158 100755
--- a/packaging/macos/jamf/scripts/repair.sh
+++ b/packaging/macos/jamf/scripts/repair.sh
@@ -74,14 +74,5 @@ esac
if [ -n "$BEACON_FALCON_CA_FILE" ]; then
set -- "$@" --falcon-ca-file "$BEACON_FALCON_CA_FILE"
fi
-# Unset leaves the endpoint's recorded choice alone, so a repair neither opts in nor out.
-case "${BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT:-}" in
- 1|true|TRUE|yes|YES)
- set -- "$@" --claude-capture-model-context
- ;;
- 0|false|FALSE|no|NO)
- set -- "$@" --claude-capture-model-context=false
- ;;
-esac
exec "$BEACON_BIN" "$@"
diff --git a/packaging/windows/install-endpoint.ps1 b/packaging/windows/install-endpoint.ps1
index 63c0ff62..e80491d0 100644
--- a/packaging/windows/install-endpoint.ps1
+++ b/packaging/windows/install-endpoint.ps1
@@ -55,11 +55,6 @@ if (-not [string]::IsNullOrWhiteSpace($collector)) { $installArgs += @('--collec
# install. Passing it explicitly is for a fleet that wants the supervised fallback instead.
if (-not [string]::IsNullOrWhiteSpace($service)) { $installArgs += @('--service', $service) }
if ($noStart -eq '1') { $installArgs += '--no-start' }
-# Unset leaves the endpoint's recorded choice alone, so a package upgrade neither opts in nor out.
-switch -Regex (Get-EnvOrDefault 'BEACON_CLAUDE_CAPTURE_MODEL_CONTEXT' '') {
- '^(1|true|yes)$' { $installArgs += '--claude-capture-model-context' }
- '^(0|false|no)$' { $installArgs += '--claude-capture-model-context=false' }
-}
Write-Output "beacon: installing the system endpoint"
& $beaconBin @installArgs