Skip to content

[FEATURE]: Plugin API: permission.reply hook to adjust the decline message before the reply settles the request #62689

Open

Description

@Fidelxyz

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Add a permission.reply plugin hook, the counterpart of permission.evaluate, that runs when a client replies to a pending permission request and lets a plugin adjust the decline message.

Motivation

In v2, Permission.reply decides how a rejection reaches the session:

  • A rejection with a message fails the request with Permission.CorrectedError. Tools convert it into a ToolFailure, toSessionError maps it to permission.rejected with the feedback text, and the model continues in the same step.
  • A rejection without a message fails the request with Permission.DeclinedError. It travels as a defect and ends the step.

The outcome therefore depends on whether the user typed text. Users and organizations that want every decline to be reported back to the model, with a standard explanation, have no supported way to configure that:

  • V1's experimental.continue_loop_on_deny is not supported in v2 (see migrate-v1.mdx).
  • permission.evaluate runs before the request is created, so it cannot see the user's reply.
  • Subscribing to Permission.Event.Replied and sending a follow-up message starts a new turn after the step has ended. The declined tool call stays recorded as aborted, and the model does not receive the explanation as that call's result.

Proposal

Trigger a permission.reply hook in Permission.reply before the reject branch decides between CorrectedError and DeclinedError:

interface PermissionReplyEvent {
  readonly sessionID: Session.ID
  readonly requestID: Permission.ID
  readonly action: string
  readonly resources: ReadonlyArray<string>
  readonly metadata?: Record<string, unknown>
  readonly source?: Permission.Source
  readonly reply: "once" | "always" | "reject"
  message?: string
}
  • The hook runs once per client reply, for the request the client answered.
  • When the final reply is reject and message is non-empty, the existing code creates CorrectedError. The same message applies to the whole batch of pending requests in the session, as it does today.
  • The reply field is read-only, so a plugin can adjust the message and cannot turn a rejection into an approval.
  • PluginHooks.Service is already available in the Permission layer, and the plugin side only needs a new entry in PermissionHooks next to evaluate.

With this hook, a plugin can fill in a default message for plain rejections:

hook.reply((event) => {
  if (event.reply === "reject" && !event.message) {
    event.message = "The user declined this tool call. Choose a different approach or ask what they prefer."
  }
})

The model then receives the text as the tool failure in the same step, which is the behavior users already get when they type a reason.

Activity

  1. opencodejr commented on Nov 8, 2026

    @opencodejr
    Contributor

    Thanks for the detailed proposal! To restate it: you'd like a permission.reply plugin hook, the counterpart of permission.evaluate. It would run in Permission.reply before a rejection settles the request, so a plugin can fill in a decline message. A plain rejection would then reach the model as a tool failure in the same step, instead of ending the step.

    I checked the code and agree that a plugin can't do this today. PermissionHooks only exposes evaluate, which runs before the request exists. Reacting to Permission.Event.Replied only works after the step has already ended. Adding a reply hook next to evaluate, with reply read-only and message writable, would cover it. I've noted this for the maintainers, who will consider it.

    Related issues:

  2. mwielgosz-esky commented on Nov 9, 2026

    @mwielgosz-esky

    One more consumer constraint worth weighing for this proposal: under the ACP protocol a client can only answer a permission request with an option id. RequestPermissionResponse carries just the outcome (selected with an optionId, or cancelled) and has no field for feedback text, so an agent driven through an ACP host has no way to pass a typed decline reason through the permission response channel itself.
    That makes the current behavior structural for that client class: human rejections routed through this response channel arrive as reject without a message; Permission.reply settles them as DeclinedError and the step ends for that request, while adapters may map user intent to different response flows. The engine itself already supports the model-visible path via CorrectedError. The proposed reply hook would give such agents a supported way to attach a default decline message at reply time, closing a gap that is not reachable through the protocol's response channel on those hosts.

  3. zevisert commented on Nov 20, 2026

    @zevisert
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions