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
{{ message }}
Repository navigation
Commit 5f9151f
Browse filesBrowse the repository at this point in the historyBrowse files
A task subagent keeps its tools when its parent was once on Deny
opencode seeds a task subagent with the parent session's deny rules only,
not the allows after them, and hides a tool when the last rule naming it is
a *-pattern deny. Rules are append-only, so a session that was on Deny once
(even for a second) kept that block's '* * deny' for life, and every child
it spawned sent its first request with no tools at all until galopin's own
rules for the child landed: the model could only answer in text, and a
background child ended there (anomalyco/opencode#45078).
Every composed block now opens with a deny that can never apply
('*' / '<galopin:subagent-tools-visible>'): children inherit it after every
older block, so their tools stay visible; it decides no call, changes
nothing for the session that owns the block, and later denies (machine
rules, the ceiling, the Deny word) still hide their tools. permission.rules
leaves it out. Existing sessions pick it up on their next prompt.
session.get also reports the model a subagent actually runs on (its newest
assistant message's), so the panel stops naming the machine's default for
it. The mock LLM records each request's tool list for the new IT.
Copy file name to clipboardExpand all lines: agent/PROTOCOL.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -178,6 +178,8 @@ _How they are applied._ (1) At `session.create` the session is created **with**
178
178
179
179
_Growth of a session's rule list (measured on 1.18.34, decided to leave as is)._ `PATCH /session/:id {permission}` only appends: the handler (`packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts`, `update`) sets `Permission.merge(current.permission ?? [], payload)`, and `merge` is a plain concatenation with no de-duplication. No endpoint, flag or `null` replaces a session's rules; the one replacing path is the deprecated per-prompt `tools` map (`session/prompt.ts`: `session.permission = <allow/deny * per tool>`), which galopin never sends (above) and which only runs inside a turn, so it cannot be used to reset then re-send. Every word change, new or removed exception, coordination grant or ceiling change therefore adds one whole composed block (about 100-150 rules; a session whose rules never change gets one). The list is not unbounded in effect, only in size: every block starts with `* * <word>`, which matches every input, so opencode's last-match-wins (`Permission.evaluate` is `findLast`) stops inside the newest block and the older ones are dead weight for evaluation. Cost, measured against a scratch opencode 1.18.34 and the mock LLM: a write-tool turn took 0.69 s with 146 rules, 0.44 s with 1,646, 0.57 s with 5,146 and 1.35 s with 20,146 (noise dominates up to a few thousand; only the extreme shows); the session record grows with the list, 13.8 KB at 146 rules, 117 KB at 1,646, 357 KB at 5,146 and 1.38 MB at 20,146 (about 70 bytes a rule), and opencode publishes the whole record on every session update. Sending only a delta was considered and not built: the rules are wildcard patterns, so "the rules whose effective action changed" is not enumerable, and a suffix delta equals the full block only when nothing in the older block's changed part still matches an input the delta does not, which cannot be proved for arbitrary agent and machine rules. A wrong delta silently softens a deny; a large session record only costs bytes. A session that has grown too large can be replaced by a new one.
180
180
181
+
_A task subagent keeps its tools (the tool-visibility sentinel)._ opencode seeds a task subagent's session with the parent session's **deny** rules only (`deriveSubagentSessionPermission`), not the allows that came after them, and hides a tool from a request when the last rule naming it, pattern ignored, is a `*`-pattern deny (`Permission.disabled`). With append-only rules, a parent that was once on Deny keeps that block's `* * deny` for life, so every child it spawned started with **every tool hidden** until galopin's own rules for the child landed; a first step can beat them by a few hundred milliseconds, and a background child has no second step, so it answered in text and ended (upstream: anomalyco/opencode#45078). galopin therefore opens every composed block with one deny that can never apply, `{"*", "<galopin:subagent-tools-visible>", "deny"}`: the child inherits it after every older block, so it is the last rule the visibility check sees for each tool, and its pattern is not `*`, so the tool stays visible. It decides no call (no wildcard, one token, no real command or path equals it), changes nothing for the session that owns the block (the block's own `* * <word>` follows it), and a deny later in the block — a machine rule, the ceiling's tail, the Deny word — still hides its tool in the child. `permission.rules` leaves it out. A session picks it up on its next prompt (its composed rules' fingerprint changes), so sessions poisoned before this release recover without a reset.
182
+
181
183
_`session_read` / `session_spawn` / `session_send`._ They have no opencode permission, so galopin looks the tool's name up in the asking session's rules (the agent's, then the session's; the machine's own rule for the name survives the selector under Ask and Allow, and Deny refuses): `allow` → no card unless the spawn is an escalation (the result carries `autoApproved:true`, the badge reads **allowed by the permission rules**), `deny` → refused with no card and none of the rate budget spent, `ask` or no rule → a `gp_` card. A **wildcard allow never grants a read** — opencode's default `"*": allow` would otherwise let any session read any transcript — **but under the Allow word it grants a spawn or a send**, like any other tool (the reads stay grant-gated because a transcript can hold secrets) — while a wildcard deny refuses them. An allow does not lift the hard limits: a send or a read into another workspace, or a send at hop 4 or more, is still carried by a card; the per-pair rate limits still refuse. "Always" on a `gp_` card is "once" and the card offers none; the Allow word never answers one.
182
184
183
185
_Coordination grant (`session.grantCoordination`, capability `coordinationGrant`)._ A scheduled run has nobody to answer a card, and no op can write a rule (`session.setRules` is retired), so the grant is the one narrow thing a client may write: `{sessionId, keys}` with `keys` drawn from `session_list`, `session_read`, `session_send`, `session_spawn` and nothing else (`invalid` otherwise, nothing recorded). galopin keeps it on the ROOT session inside the same record as the selector (the session overlay, `coordination`), so it **survives a restart** like an exception does, and composes it as one `allow` per key **after the mode block and before the machine's own rules for the tools** — and so beneath the ceiling's tail, which is last. What that makes of it:
0 commit comments