Skip to content

Approved tools never run when excludeToolMessages is true #409

Closed

Description

@robelest

With contextOptions: { excludeToolMessages: true }, continuing a generation after agent.approveToolCall never executes the approved tool. excludeToolMessages is applied to the exchange being continued, so the context drops the tool call, the approval request and the decision (which is stored as a tool message), and the model is called with the history ending at the user's prompt.

Repro: an agent with a needsApproval tool and excludeToolMessages: true; prompt it so the model calls the tool; approveToolCall; then generateText with the returned promptMessageId. The tool's execute is never called.

This has been the case since approvals were added in #222; default options (tool messages included) are unaffected.

Activity

  1. as992949791 commented on Oct 22, 2026

    @as992949791

    Local reproduction confirmed on main 2405f035: the existing native approval scenario passes with excludeToolMessages: false, but with true the resumed generateText leaves the tool execution list empty instead of executing the approved call. The regression uses the public approveToolCall method and its returned message ID.

    I am preparing a focused fix that restores the persisted approval continuation while keeping ordinary historical tool messages excluded. I checked the current #416 patch: it changes approval/context-handler preparation, but leaves the exclusion query in place and still requires the filtered continuation message, so this case appears separate. I will keep the change limited to this option interaction and cover denied decisions and message/thread boundaries.

    Investigation and local regression tests used AI assistance; no paid-provider calls were needed.

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