Skip to content

[Bug]: Tool input schema is validated after permission confirmation — users are asked to confirm calls that will fail validation #3320

Open

Description

@xuchaoguo1983

Describe the bug
For a registered tool that requires confirmation (ASK), the permission gate runs before the executor validates the tool input against the tool's schema. So when the model produces a call that violates the schema (missing required property, wrong type), the user is asked to confirm it first. The schema error only comes back after the user approves, and the tool never runs.

The user has to approve a call that can never execute. In an AG-UI app this shows up as a confirmation card for a malformed operation. The model also cannot fix its own malformed call without a round trip through the user.

To Reproduce

  1. Register a @Tool with a required String parameter scope, and add an ask rule for it.
  2. Have the model call it with {}, or with {"scope": {"x": 1}}.
  3. A permission confirmation (RequireUserConfirmEvent, AG-UI interrupt) is emitted.
  4. Approve it. The tool result is Error: Parameter validation failed for tool '...': : required property 'scope' not found (or /scope: object found, string expected), and the tool is not executed.

Verified on 2.0.3 and on main (857e3e6) with a scripted model. In ReActAgent, evaluatePermissions / evaluateOne run before execution, and the schema check happens in the executor. executeStructuredTool notes that it mirrors "the schema validation the executor performs for registered tools".

Expected behavior
Validate the input against the tool schema before the permission gate. A call that fails validation should return the validation error to the model directly, as it does for tools that need no confirmation, without asking the user. This matches common agent-harness practice of validating input before prompting for permission.

Environment
AgentScope-Java 2.0.3 and main (857e3e6), JDK 21.

Activity

  1. kalayciburak commented on Sep 27, 2026

    @kalayciburak

    I will take this. The fix validates the tool input against its schema before the permission gate, and returns the same validation error the executor already produces, without asking the user to confirm a call that cannot run. A regression test will cover a missing required property and a wrong type, and a valid call will still pause for confirmation.

  2. oss-maintainer commented on Sep 27, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: bug | Status: Confirmed — medium severity (verified against main @ 857e3e6c by read-only analysis of the call chain; no repository files were modified)

    The reported ordering is real. On the ASK path the permission gate runs first and input/schema validation happens only inside the executor, so a call that can never validate still produces a confirmation prompt.

    Call chain

    Step Location Code
    Permission gate first agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java:3069 actingStream → evaluatePermissions(toolCalls) before any execution
    Per-call decision ReActAgent.java:3395 (evaluatePermissions), :3420 (evaluateOne) Resolves the tool, then permissionEngine.checkPermission(tb, input) or legacy tb.checkPermissions(...) — no ToolValidator call anywhere in ReActAgent except :3695
    Confirmation emitted ReActAgent.java:3131 new RequireUserConfirmEvent(replyId, pending) + RequestStopEvent(PERMISSION_ASKING); runToolBatch is only reached when pending.isEmpty() (:3100)
    After approval ReActAgent.java:3164 → :3573 → :3625 runToolBatch → executeToolCalls → dispatchToolCalls
    Into the toolkit io/agentscope/core/tool/Toolkit.java:614 → :628 callTools(...) → executor.executeAll(...) (ToolExecutor.java:374)
    First schema check io/agentscope/core/tool/ToolExecutor.java:201 (executeCore), :231-242 ToolValidator.validateInput(toolCall.getContent(), tool.getParameters()) (:233)
    Error text ToolExecutor.java:236-239 "Parameter validation failed for tool '%s': %s\nPlease correct the parameters and try again."

    Notes on the reporter's specifics:

    • executeStructuredTool (ReActAgent.java:3694, Javadoc at :3690-3691) does mirror the executor validation as stated, but it is also reached only inside dispatchToolCalls — i.e. behind the gate — so it does not change the confirmation ordering.
    • The non-ASK path has the same ordering; validation is deferred, not skipped (ALLOW/PASSTHROUGH/DENY go straight to runToolBatch). The defect is user-visible precisely because ASK pauses for a human.

    Impact: the user is asked to approve an operation that is guaranteed to fail, and the model needs an extra user round trip to learn its call was malformed. In an AG-UI app this renders as a confirmation card for a call that can never execute. The tool does not run and no data is corrupted.

    Suggested minimal fix. ToolValidator.validateInput(String input, Map<String,Object> schema) is already public (tool/ToolValidator.java:77) and evaluateOne already resolves the tool via activeToolkit.getTool(...) — so the check can be added there before the engine/legacy permission call, letting schema-invalid calls fall through to the existing executor path that emits the identical validation error. A more complete variant validates earlier in actingStream, removes the invalid calls from the gated set, and synthesizes their ToolResultBlock errors directly, which avoids the double validation pass and preserves DENY semantics.

    Behavior decisions worth making explicit: an invalid call that would have matched a DENY rule now returns a validation error instead of a permission denial; legacy tools whose checkPermissions asks on invalid input stop asking. Mixed batches must still pause for the genuinely valid ASK calls — that case needs its own test.

    Test coverage today: ToolExecutorTest asserts the validation message inside the executor; ReActAgentHitlTest covers pause/resume with valid input only; PermissionEngineTest covers rule resolution in isolation. Nothing asserts that a schema-invalid call bypasses RequireUserConfirmEvent, so a fix should add: (1) required-param tool + ASK rule called with {} → no confirmation event, validation error returned; (2) the same through the legacy ToolBase#checkPermissions path; (3) a mixed batch (one valid ASK + one invalid) where only the valid call asks.

    Duplication: PR #3321 (fix(agent): validate tool input before the permission gate, @kalayciburak) already claims this issue and moves validation ahead of evaluatePermissions in actingStream. Reviewing that PR is the right next step; no competing change will be opened here.


    Automated evaluation by github-manager (oss-maintainer)

  3. added
    area/core/agent
    area/core/tool
    bug
    on Sep 27, 2026
  4. added a commit that references this issue on Sep 27, 2026
    d8809eb
  5. added 4 commits that reference this issue on Oct 23, 2026
    fcaec49
    7b38e94
    261e948
    4afe427
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/core/agentarea/core/toolbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions