Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(activity-log): label sandbox rows in the audit log ip column (#105746)

Yasen241e3c5a80f0
diff --git a/docs/internal/activity-logging.md b/docs/internal/activity-logging.md
index aae265df9ff6..5d300569bf2a 100644
--- a/docs/internal/activity-logging.md
+++ b/docs/internal/activity-logging.md
@@ -181,6 +181,8 @@ Only the activity log uses the rules below. Throttles, IP allowlists, and reques
The `posthog_mcp_client_ip_verifications` counter records each outcome.
- **Sandbox agents.** A row written with an OAuth token bound to a sandbox task keeps the request IP.
The token can leave the sandbox, so the IP is what tells a sandbox write apart from a write made elsewhere with the same token.
+ The audit log IP address column shows a dash for these rows, with the IP in its tooltip.
+ The User column tags a scout run "via scout <skill_name>" and any other sandbox task "via sandbox".
A model with a fail-closed manager (`TeamScopedRootMixin`, `ProductTeamModel`) raises `TeamScopeError` on any query without team context.
The mixin's before-update read is by primary key without a team filter (`unscoped()`), so a `save()` outside a request works.
diff --git a/docs/published/handbook/engineering/ai/sandboxed-agents.md b/docs/published/handbook/engineering/ai/sandboxed-agents.md
index ae09303ca711..23691cb6f777 100644
--- a/docs/published/handbook/engineering/ai/sandboxed-agents.md
+++ b/docs/published/handbook/engineering/ai/sandboxed-agents.md
@@ -224,6 +224,7 @@ Every other client keeps the self-reported header value.
A row written with a token bound to a sandbox task still records the request IP address.
The token can leave the sandbox, so the address is what tells a sandbox write apart from a write made elsewhere with the same token.
+The audit log tags these rows "via scout <skill_name>" or "via sandbox", and shows the IP in a tooltip on the IP address column.
## PostHog MCP server
diff --git a/frontend/src/scenes/audit-logs/AuditLogTable.tsx b/frontend/src/scenes/audit-logs/AuditLogTable.tsx
index ff5bcbc21aad..c21b0818d273 100644
--- a/frontend/src/scenes/audit-logs/AuditLogTable.tsx
+++ b/frontend/src/scenes/audit-logs/AuditLogTable.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react'
-import { LemonTabs } from '@posthog/lemon-ui'
+import { IconInfo } from '@posthog/icons'
+import { LemonTabs, LemonTag } from '@posthog/lemon-ui'
import { ActivityClientTag } from 'lib/components/ActivityLog/ActivityClientTag'
import { AGENT_INTENT_TOOLTIP } from 'lib/components/ActivityLog/AgentAttribution'
@@ -15,6 +16,8 @@ import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { urls } from 'scenes/urls'
+import { sandboxChange } from './sandboxChange'
+
export interface AuditLogTableProps {
logItems: HumanizedActivityLogItem[]
pagination?: PaginationManual
@@ -22,6 +25,10 @@ export interface AuditLogTableProps {
teamsById?: Record<number, string>
}
+const SANDBOX_IP_TOOLTIP = 'This change used a token that PostHog issued for a sandbox task.'
+const SANDBOX_TAG_TOOLTIP =
+ 'This change used a token that PostHog issued for a sandbox task. PostHog records this, so it is not self-reported.'
+
const baseColumns: LemonTableColumns<HumanizedActivityLogItem> = [
{
title: 'Description',
@@ -54,6 +61,13 @@ const baseColumns: LemonTableColumns<HumanizedActivityLogItem> = [
size="md"
/>
{logItem.unprocessed?.client && <ActivityClientTag client={logItem.unprocessed.client} />}
+ {sandboxChange(logItem)?.needsSandboxTag && (
+ <Tooltip title={SANDBOX_TAG_TOOLTIP}>
+ <LemonTag size="small" type="muted">
+ via sandbox
+ </LemonTag>
+ </Tooltip>
+ )}
</div>
),
width: '20%',
@@ -83,12 +97,23 @@ const baseColumns: LemonTableColumns<HumanizedActivityLogItem> = [
{
title: 'IP address',
key: 'ip_address',
- render: (_, logItem) =>
- logItem.unprocessed?.ip_address ? (
- <span className="font-mono text-xs">{logItem.unprocessed.ip_address}</span>
+ render: (_, logItem) => {
+ const ipAddress = logItem.unprocessed?.ip_address
+ if (sandboxChange(logItem)) {
+ return (
+ <Tooltip title={ipAddress ? `${SANDBOX_IP_TOOLTIP} Request IP: ${ipAddress}` : SANDBOX_IP_TOOLTIP}>
+ <span className="inline-flex items-center gap-1 text-muted">
+ — <IconInfo />
+ </span>
+ </Tooltip>
+ )
+ }
+ return ipAddress ? (
+ <span className="font-mono text-xs">{ipAddress}</span>
) : (
<span className="text-muted">—</span>
- ),
+ )
+ },
width: '10%',
},
]
diff --git a/frontend/src/scenes/audit-logs/sandboxChange.test.ts b/frontend/src/scenes/audit-logs/sandboxChange.test.ts
new file mode 100644
index 000000000000..8cf54534836d
--- /dev/null
+++ b/frontend/src/scenes/audit-logs/sandboxChange.test.ts
@@ -0,0 +1,53 @@
+import { HumanizedActivityLogItem, Trigger } from 'lib/components/ActivityLog/humanizeActivity'
+import { dayjs } from 'lib/dayjs'
+
+import { ActivityScope } from '~/types'
+
+import { SandboxChange, sandboxChange } from './sandboxChange'
+
+const AGENT_TASK_ID = '019f4c2a-0000-7000-8000-0000000000aa'
+
+describe('sandboxChange', () => {
+ function logItem(client: string | null, trigger: Trigger | null): HumanizedActivityLogItem {
+ return {
+ description: 'changed the tile query on Weekly signups',
+ created_at: dayjs('2026-09-14T12:00:00Z'),
+ unprocessed: {
+ activity: 'updated',
+ created_at: '2026-09-14T12:00:00Z',
+ scope: ActivityScope.DASHBOARD,
+ client,
+ ip_address: '198.51.100.24',
+ detail: { merge: null, trigger, changes: null, name: 'Weekly signups' },
+ },
+ }
+ }
+
+ it.each([
+ [
+ 'a scout run, whose client tag already names the scout',
+ 'scout:signals-scout-errors',
+ { job_type: 'agent', job_id: AGENT_TASK_ID, payload: {} },
+ { needsSandboxTag: false },
+ ],
+ [
+ 'another sandbox task',
+ 'mcp',
+ { job_type: 'agent', job_id: AGENT_TASK_ID, payload: {} },
+ { needsSandboxTag: true },
+ ],
+ [
+ 'an agent with intent but no task binding',
+ 'mcp',
+ { job_type: 'agent', job_id: '', payload: { intent: 'Repairing a broken tile' } },
+ null,
+ ],
+ ['a self-reported client', 'posthog-js/1.234.0', null, null],
+ ['a background job', null, { job_type: 'hog_flow', job_id: '1234', payload: {} }, null],
+ ] as [string, string | null, Trigger | null, SandboxChange | null][])(
+ 'reads %s',
+ (_label, client, trigger, expected) => {
+ expect(sandboxChange(logItem(client, trigger))).toEqual(expected)
+ }
+ )
+})
diff --git a/frontend/src/scenes/audit-logs/sandboxChange.ts b/frontend/src/scenes/audit-logs/sandboxChange.ts
new file mode 100644
index 000000000000..af3f8e8ae086
--- /dev/null
+++ b/frontend/src/scenes/audit-logs/sandboxChange.ts
@@ -0,0 +1,20 @@
+import { isScoutClient } from 'lib/components/ActivityLog/activityClientLabel'
+import { HumanizedActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
+import { parseAgentAttribution } from 'lib/components/ActivityLog/parseAgentAttribution'
+
+export interface SandboxChange {
+ /** A scout run's client tag already names the scout, so only other sandbox tasks need a tag. */
+ needsSandboxTag: boolean
+}
+
+/**
+ * The row used a token bound to a sandbox task. The token can leave the sandbox, so this says which
+ * token made the change, not where the request came from. Only that binding writes a task id.
+ */
+export function sandboxChange(logItem: HumanizedActivityLogItem): SandboxChange | null {
+ if (!parseAgentAttribution(logItem)?.taskId) {
+ return null
+ }
+ const client = logItem.unprocessed?.client
+ return { needsSandboxTag: !(client && isScoutClient(client)) }
+}