Skip to content

Permission decisions are not observable in the tool result or session record #64383

Open

Description

@martinderm

Summary

After a user approves a permission card, the tool result received by the agent is a normal success/allow. It contains no request identifier, decision, actor, or timestamp, and the session record has no permission field. The agent therefore cannot distinguish a configuration allow from a user-approved ask.

Environment

  • OpenCode 2.3.0 (Windows)
  • OpenChamber 2.7.2 (UI/card host)
  • Permission modes safety and ask
  • File tools (write, edit), action edit; FileWrite.authorize

Observed

  1. A tool call matches an edit: ask rule.
  2. The UI shows a permission card; the user approves it.
  3. The tool call returns a normal success (for example Created file successfully).
  4. The session record and the tool result contain no indication that a permission request occurred or how it was decided.

The permission.asked event exists and is handled by the card host, but it is not queryable by the agent or persisted with request/session identity in a way the agent can cite.

Consequence

An agent cannot attest whether a write was allowed by configuration or by a human approval. A probe that expects ask reports allow and may incorrectly conclude that no card appeared; we observed exactly this misreport before the user confirmed the cards. For audit and test evidence, the permission decision is not attributable.

Proposal

One of:

  1. Attach a permission decision reference to the tool result: request id, action, resource, effect, actor, timestamp — or at least a boolean permission_requested/permission_approved.
  2. Persist permission.asked / permission.replied with request and session identity in a queryable session event or DB, exposed via the API.
  3. If neither is intended, document explicitly that agent-side ask attestation is impossible and that only the UI/user channel can prove it.

Non-goals

The opt-in timeout/deny behavior for unanswered requests is a separate OpenChamber issue (openchamber/openchamber#7026). This issue is about observability and attestation of the decision itself.

Evidence notes

  • Tool result after approval: normal success, no extra fields.
  • Session record: no permission/mode field.
  • UI: permission card visible; approval accepted.
  • No secrets or session data are included here.

Activity

  1. opencodejr commented on Nov 17, 2026

    @opencodejr
    Contributor

    Thanks for the clear write-up, @martinderm. As I understand it, you want an agent, and later an audit, to be able to tell a tool call allowed by configuration from one a person approved through an ask prompt. That means putting the permission decision (request id, action, resource, effect, actor, timestamp) on the tool result or storing it with the session.

    From the code, this is how it currently works rather than a bug. permission.asked and permission.replied are defined as ephemeral events, so they are not stored in the session history. The tool result has no permission field. I've marked this as a feature request, and the maintainers will consider it. I can't say what they'll decide.

    Related issues:

    Until then, a plugin can cover much of your first proposal. It subscribes to the permission events and uses the execute.after tool hook to add the decision to the tool result, so the agent sees it and it is saved with the result. I type-checked this against @opencode/plugin but haven't run it in a live session. Save it as .opencode/plugins/permission-audit/index.ts (plugins there load automatically):

    import { Plugin } from "@opencode/plugin"
    
    type Decision = {
      requestID: string
      action: string
      resources: readonly string[]
      askedAt: string
      reply?: "once" | "always" | "reject"
      repliedAt?: string
    }
    
    export default Plugin.define({
      id: "permission-audit",
      async setup(ctx) {
        // tool call ID -> permission requests raised for that call
        const byCall = new Map<string, Decision[]>()
        const byRequest = new Map<string, Decision>()
        const controller = new AbortController()
    
        void (async () => {
          for await (const event of ctx.event.subscribe({
            types: ["permission.asked", "permission.replied"],
            signal: controller.signal,
          })) {
            if (event.type === "permission.asked") {
              const source = event.data.source
              if (source?.type !== "tool") continue
              const decision: Decision = {
                requestID: event.data.id,
                action: event.data.action,
                resources: event.data.resources,
                askedAt: new Date().toISOString(),
              }
              byRequest.set(decision.requestID, decision)
              byCall.set(source.id, [...(byCall.get(source.id) ?? []), decision])
              continue
            }
            const decision = byRequest.get(event.data.requestID)
            if (!decision) continue
            decision.reply = event.data.reply
            decision.repliedAt = new Date().toISOString()
          }
        })()
    
        await ctx.tool.hook("execute.after", (event) => {
          const decisions = byCall.get(event.id)
          byCall.delete(event.id)
          for (const d of decisions ?? []) byRequest.delete(d.requestID)
          if (event.status !== "completed") return
          const permission = decisions?.length
            ? { prompted: true, decisions }
            : { prompted: false } // allowed by a rule or a saved approval, no prompt was shown
          const note = decisions?.length
            ? `[permission] ${decisions.map((d) => `${d.action} ${d.resources.join(", ")}: user replied "${d.reply ?? "unknown"}" (request ${d.requestID})`).join("; ")}`
            : "[permission] no permission prompt was shown for this call"
          const content = event.result.content
          event.result = {
            ...event.result,
            metadata: { ...event.result.metadata, permission },
            content:
              content === undefined
                ? note
                : typeof content === "string"
                  ? `${content}\n\n${note}`
                  : [...content, { type: "text", text: note }],
          }
        })
    
        return () => controller.abort()
      },
    })

    Limits:

    • It can tell "a prompt was shown and the user replied once/always" apart from "no prompt". It can't tell whether a call with no prompt was allowed by a rule or by a saved approval.
    • The replied event carries no actor, so the timestamps are the plugin's own.
    • It keeps state in memory only.

    Closing those gaps would need core support, such as a hook or field that reports the final permission decision for each tool call.

  2. added
    area/core
    type/feature
    version/v2
    on Nov 17, 2026
  3. martinderm commented on Nov 18, 2026

    @martinderm
    Author

    Empirical data point on the saved-approval side

    Thanks for the triage and the plugin sketch. The plugin helps for the prompted case, but the no-prompt case is not just ambiguous in theory. We audited a real multi-project Windows setup (OpenCode 2.3.0, OpenChamber 2.7.2):

    • The permission table holds 159 saved approvals across 18 project records; 127 are active, 32 legacy (V1-only or zero sessions). The busiest project alone has 53.
    • Many are broad: python -B *, python -X *, opencode *, git -C *, git checkout *, git push *, gh pr merge *, gh repo create *, Remove-Item *, Stop-Process *, Get-Content *.
    • A saved allow is appended after the configured rules and takes precedence over ask, so no card appears. Your plugin then reports prompted: false — exactly the case it cannot distinguish from "allowed by configuration". In the busiest project this affects 35 broad entries.
    • The existing reset/clean/force-push denies are also not fully effective: git -C * matches git -C repo reset --hard, and git push * is additionally allowed in the build agent.

    So prompted: false cannot be used as an attestation, and #48456 is not theoretical. Two questions:

    1. Is there a supported way to enumerate/revoke saved approvals (API/CLI), or is the permission table the only interface?
    2. Is a core field for the final permission decision per tool call planned, or should we treat the UI/user channel as the only proof for now?

    No secrets or session data are included; only aggregate counts and generic patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreplatform/windowstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions