You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`SANDBOX_MCP_URL`overrides the `host.docker.internal` default (which only resolves from local Docker sandboxes, not Modal). Without it, sandbox agents can't reach the MCP server and lose access to the PostHog `execute-sql`, query, and tool-calling stack.
179
179
180
+
### Agent run telemetry (optional)
181
+
182
+
To ship agent-server run metadata to PostHog Logs, set both of the first two; the third additionally produces one APM trace per run (root `task_run` span, a `turn` span per prompt, a `tool_call:<kind>` span per tool call) with trace/span ids stamped on the log records:
183
+
184
+
```bash
185
+
SANDBOX_AGENT_OTEL_LOGS_URL=http://localhost:8000/i/v1/logs # or https://us.i.posthog.com/i/v1/logs
186
+
SANDBOX_AGENT_OTEL_LOGS_TOKEN=<project API key of the telemetry project>
In cloud, emission is additionally gated per run by the `tasks-agent-run-otel-telemetry` feature flag (org-targeted, stamped into run state at dispatch; it also gates the scout run-log mirror). `DEBUG` bypasses the flag, so locally these settings are the only switch. They're injected into the sandbox as `POSTHOG_AGENT_OTEL_LOGS_URL`/`_TOKEN`/`POSTHOG_AGENT_OTEL_TRACES_URL` (deliberately not standard `OTEL_*` names, so OTel SDKs in user code don't auto-export into the telemetry project).
191
+
The agent-server exports run/turn/tool lifecycle metadata (never message content or tool arguments), tagged with `run_id`/`task_id`/`team_id`/`user_id`/`distinct_id` resource attributes and `service.name=posthog-code-agent`.
192
+
Telemetry stays off when either of the first two vars is unset.
193
+
For local Docker sandboxes the localhost URLs are rewritten to `host.docker.internal` automatically; local ingestion requires the `capture-logs` service to be running.
194
+
180
195
### MCP server `.env`
181
196
182
197
`MODAL_DOCKER`(and the local Docker provider) both depend on the MCP server running at `localhost:8787`. The server reads its config from `services/mcp/.env` — without it, things like `POSTHOG_API_BASE_URL`, the UI-apps token, and analytics keys are missing and the server will either refuse to start or return broken responses to the sandbox.
@@ -237,6 +252,39 @@ repositories.
237
252
238
253
> **Note:** This only works with `SANDBOX_PROVIDER=docker`.
239
254
255
+
### Task-run log mirroring to PostHog Logs (dogfooding)
256
+
257
+
Task-run log entries (the JSONL appended to object storage via `TaskRun.append_log`) are also mirrored into the PostHog Logs product,
258
+
so runs can be browsed and sampled in the Logs UI instead of fetching S3 blobs.
259
+
260
+
In production there is no transport of its own: entries are emitted as structured stdout log lines (`event=task_run_log`),
261
+
and the per-cluster OTel collector that already ships all container stdout into the region's internal PostHog project picks them up.
262
+
The collector parses each JSON key into a queryable attribute and turns the emitted `request_id` (the run uuid) into a trace id,
263
+
so one run groups as a trace and can be pulled up with an attribute filter on `task_run_id`.
264
+
265
+
```bash
266
+
# Which task origins to mirror (comma-separated). Defaults to signals scouts only.
0 commit comments