Skip to content

feat(agent): configure PostHog exec permissions#3578

Open
skoob13 wants to merge 4 commits into
mainfrom
feat/configurable-posthog-exec-permissions
Open

feat(agent): configure PostHog exec permissions#3578
skoob13 wants to merge 4 commits into
mainfrom
feat/configurable-posthog-exec-permissions

Conversation

@skoob13

@skoob13 skoob13 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Interactive cloud runs could bypass PostHog MCP exec approvals in hands-off permission presets, while the gated sub-tools were hardcoded and Claude-specific.

Changes

  • add a shared case-insensitive regex gate with the default (^|-)(partial-update|update|patch|delete|destroy)(-|$)
  • allow cloud provisioning to override the regex with --posthogExecPermissionRegex
  • delegate matching cloud Claude requests to AgentServer, which uses getEffectiveMode to relay or buffer interactive approvals and auto-approve background runs
  • preserve hands-off behavior for local Claude auto and bypassPermissions sessions
  • let Claude users remember exact sub-tool approvals in repository-local settings while keeping Codex approvals one-time
  • reject permission responses for options that were not offered

How did you test this code?

  • focused Vitest coverage for the shared matcher, Claude local and cloud permissions, remembered approvals, disconnected buffering, Codex, schemas, and AgentServer interactive and background routing
  • agent TypeScript typecheck
  • agent package build, including bundled local-tools verification
  • Biome checks on changed files
  • the repository-wide pre-commit typecheck remains blocked by unrelated existing @posthog/web errors from missing @posthog/quill exports; @posthog/agent typecheck passes

Publish to changelog?

Do not publish to changelog.

@trunk-io

trunk-io Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit a47c38c.

@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(agent): configure PostHog exec perm..." | Re-trigger Greptile

@posthog

posthog Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

Comment thread packages/agent/src/adapters/claude/claude-agent.ts Outdated
@veria-ai

veria-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 4 · PR risk: 0/10

Comment thread packages/agent/src/posthog-exec-permission.ts
@skoob13
skoob13 requested review from a team and tatoalo July 20, 2026 13:09
Comment thread packages/agent/src/adapters/codex-app-server/codex-app-server-agent.ts Outdated
@skoob13
skoob13 force-pushed the feat/configurable-posthog-exec-permissions branch from 473168f to 98d2308 Compare July 20, 2026 14:13
@skoob13
skoob13 force-pushed the feat/configurable-posthog-exec-permissions branch from 98d2308 to bdf0d87 Compare July 20, 2026 14:23
Review fixes for the configurable exec-permission feature: restore the needs_approval check ahead of the Claude exec gate so an explicit ask-me setting can't be bypassed by remembered approvals or hands-off modes; validate _meta.posthogExecPermissionRegex through the shared Zod schema in both adapters, warning and falling back to the default instead of crashing or silently flipping gating; filter Codex exec sub-tools in the adapter's approval handlers so local sessions only prompt for matching destructive calls (with Claude-parity hands-off in auto/full-access); make toCodexMcpServers take an honest gatePosthogExec flag; return a discriminated result from resolvePermission with distinct errors for unknown requests vs unoffered options; exempt question responses (synthetic option_<idx> ids) from the offered-option check, which was hanging cloud question relays; parse exec input via Zod; document the posthog server-name contract; unwrap README prose.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants