Skip to content

Stop agent-forked workers from running with more permissions than their lead - #1612

Merged
currentbits merged 10 commits into
mainfrom
coder/p1-bind-the-caller-s-thread-id-at-the-mc-11d82e
Oct 13, 2026
Merged

currentbits merged 10 commits into
mainfrom
coder/p1-bind-the-caller-s-thread-id-at-the-mc-11d82e

Conversation

@currentbits

Copy link
Copy Markdown
Owner

What

Workers that an agent forks can no longer run in a higher permission mode than the thread that forked them (#1425).

The escalation came from mode snapping. When a lead runs default on Claude and forks a worker on Grok or Kimi, the worker snaps to bypassPermissions, because those headless CLIs only honour full access. Before this change, any agent could get a full-access worker that way, just by naming a provider or pool alias.

Changes

  • assertWorkerNarrows (electron/services-threads.js): snaps the lead's mode on both the lead's provider and the worker's provider, then compares the two by rank (plan < default < acceptEdits < bypassPermissions). If the worker ranks higher, it throws runtime_mode_escalation_denied. The error message tells the agent how to get unblocked: pick a worker that honours the lead's mode, or ask the user.
  • forkWorkerThread: calls the check before it creates any thread. This covers both pool aliases and the legacy provider argument. It skips the check when userPicked: true.
  • @provider composer turns (runner-turn-setup.js): these pass userPicked: true. The user typed the provider, so a mode jump is their decision, the same as a sidebar fork.
  • Pool failover (subagentPool.js): startWithPoolFailover runs the same check before it switches a worker onto the next pool entry, so failover can't escalate either.
  • allowEscalation on pool entries: this optional boolean is the only override. It's validated as a boolean, kept through normalize, and added to the SubagentPoolEntry IPC type. Users can only set it in Settings; no tool argument can grant it.
  • Settings → Agents (AgentsPane.tsx): the pool form gets an "Allow more permissions than the lead" checkbox with an explanatory note. Aliases that have it turned on are labelled "may exceed the lead's permissions" in the list.

Known gap

The check ignores Teach caps. That's fine because Teach caps only ever lower a worker's mode (see the ponytail: comment).

Tests

  • New worker privilege narrowing (#1425) suite in subagent-pool.test.js. It covers:
    • an escalating pool alias and a legacy provider: "grok" argument are both refused, and no worker thread is created;
    • same-mode workers, a bypass lead and a flagged alias are allowed;
    • failover refuses to switch onto an escalating entry;
    • allowEscalation validation.
  • Existing Kimi pool fixtures in services.test.js and project-thread-defaults.test.js now set allowEscalation: true, because Kimi only runs in bypass mode.

🤖 Generated with Claude Code

Willem and others added 6 commits October 12, 2026 12:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T20:18:20.648272Z 7f3a5e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f3a5e04e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

resolved && resolved.fromPool
? poolFromStore(store).entries.find((e) => e.alias === resolved.alias)
: null;
assertWorkerNarrows(source, forkInput.provider, poolEntry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recheck permissions after applying a routed tier

When a default Claude lead calls thread_fork with a tier mapped to Grok or Kimi, this validates only the fork's initial inherited provider. thread_fork then attaches the requested route in electron/orchServer.js:461-470, and applyRoute switches providers during startRun; setProvider consequently snaps the worker to bypassPermissions without invoking this guard. An agent can therefore bypass the new restriction simply by selecting tier instead of provider; validate the routed profile against the lead before starting it, or enforce the invariant whenever an orchestration worker changes provider.

Useful? React with 👍 / 👎.

Comment thread electron/orchServer.js
: {}),
trigger: hasTrigger ? { type: "github", ...triggerRaw } : null,
tier: args && args.tier,
...(args && args.memory != null ? { memory: args.memory } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add memory to the automation tool schema

When an agent tries to create an automation with memory, this new forwarding path is unreachable through the registered MCP tool: the automation_create input schema at electron/orchServer.js:1711-1739 declares the other arguments but omits memory, so tool clients neither expose nor accept the field. As a result, chat-authored automations cannot persist the optional memory promised by the accompanying design despite the handler appearing to support it; add an optional string field to the tool schema.

Useful? React with 👍 / 👎.

Willem and others added 4 commits October 13, 2026 08:44
Store round-trip and automation_create assertions predate prLinks on
threads and the Linear/Sentry trigger fields (#1588); main is red on both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ler-s-thread-id-at-the-mc-11d82e

# Conflicts:
#	electron/test/automation-create-mcp.test.js
@currentbits
currentbits merged commit 2a8af4c into main Oct 13, 2026
6 checks passed
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.

1 participant