openclaw - ✅(Solved) Fix [Bug]: sessions_yield tool available even when removed from tool policy allowlist [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#83981Fetched 2026-05-20 03:45:38
View on GitHub
Comments
1
Participants
2
Timeline
18
Reactions
1
Timeline (top)
labeled ×13unlabeled ×3commented ×1cross-referenced ×1

sessions_yield can be called by the agent even if it is removed from the tool allowlist/denylist policies. Agents randomly use it mid-task as if it were always available, regardless of configuration.

Error Message

When sessions_yield is not in the effective tool allowlist (after policy and config resolution), the tool must not be available to agents, and must never appear in the effective tool list, tool catalog, or agent prompt surface. Any attempt to invoke it must error out (not update state or fire the onYield callback).

Root Cause

Root cause: sessions_yield is always created by createOpenClawTools regardless of policy, with the callback attached. Allow/deny filtering happens after the tool and callback are wired up, so the agent can discover and use this tool. Mitigation: Tool must NOT be created at all unless present in the effective tool policy for the session/agent. See also https://github.com/openclaw/openclaw/blob/cc835b6d72765ff81aeab7d8ad8628b425c24547/src/agents/openclaw-tools.ts#L452

Fix Action

Fix / Workaround

Root cause: sessions_yield is always created by createOpenClawTools regardless of policy, with the callback attached. Allow/deny filtering happens after the tool and callback are wired up, so the agent can discover and use this tool. Mitigation: Tool must NOT be created at all unless present in the effective tool policy for the session/agent. See also https://github.com/openclaw/openclaw/blob/cc835b6d72765ff81aeab7d8ad8628b425c24547/src/agents/openclaw-tools.ts#L452

PR fix notes

PR #84000: fix(agents): respect tool policy for sessions_yield [AI-assisted] (#83981)

Description (problem / solution / changelog)

🤖 AI-assisted (built with Codex via Hermes orchestration). Test level: lightly tested. Prompt summary available on request.

Summary

  • Problem: sessions_yield was always built and registered inside createOpenClawTools, regardless of the effective tool policy. Allow/deny filtering only ran later in the pipeline, so agents could still discover and invoke sessions_yield even when tools.deny listed it or when an explicit tools.allow excluded it.
  • Why it matters: Agents would intermittently call sessions_yield mid-task in restricted-policy contexts, ending the turn unexpectedly and forcing manual resume. Policy expectations were silently violated.
  • What changed: Gate sessions_yield at construction time using isToolAllowedByPolicyName against the same explicitFactoryAllowlist / explicitFactoryDenylist already used for message and update_plan. The tool is no longer created (and its onYield callback no longer wired) when policy disallows it.
  • What did NOT change (scope boundary): No changes to the tool's runtime behavior, to other tools, to filter pipelines downstream, to subagent inheritance, or to plugin tool resolution.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Agents

Linked Issue/PR

  • Closes #83981
  • This PR fixes a bug or regression

Root Cause

  • Root cause: createSessionsYieldTool was always present in the tools array literal in src/agents/openclaw-tools.ts. Allow/deny resolution happened after the tool and its callback were already constructed, so it remained visible in the effective tool catalog and could still be invoked.
  • Missing detection / guardrail: No unit test asserted that sessions_yield is omitted from createOpenClawTools output when tools.deny or a narrow tools.allow excludes it. Other gated tools (message, update_plan) had this proof; sessions_yield did not.
  • Contributing context (if known): sessions_yield was added as a default-on tool; the pattern of gating at construction time (mirrored from message/update_plan) was not extended to it.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/agents/openclaw-tools.sessions-yield-policy.test.ts
  • Scenario the test should lock in: createOpenClawTools includes sessions_yield by default, but omits it when tools.deny contains sessions_yield, when a narrow tools.allow does not list it, and when pluginToolDenylist contains it.
  • Why this is the smallest reliable guardrail: It exercises the exact public factory entry point and asserts the resulting tool inventory, which is what agents and the catalog ultimately consume.
  • Existing test that already covers this (if any): N/A
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • When tools.deny lists sessions_yield (or an explicit tools.allow excludes it), the tool is no longer offered to agents and cannot be invoked. Default behavior (no policy) is unchanged: sessions_yield remains available.

Security Impact (required)

  • New permissions/capabilities? No
  • This change tightens an existing capability gate (policy is now honored for sessions_yield as for other gated tools). It can only reduce, not expand, what an agent can do in a given configuration.

Changed files

  • src/agents/openclaw-tools.sessions-yield-policy.test.ts (added, +52/-0)
  • src/agents/openclaw-tools.ts (modified, +13/-4)

Code Example

See related logs: agent fires sessions_yield after policy disables it, onYield() invoked, status is yielded. Also confirmed in agent UI where the tool call is surfaced.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

sessions_yield can be called by the agent even if it is removed from the tool allowlist/denylist policies. Agents randomly use it mid-task as if it were always available, regardless of configuration.

Steps to reproduce

  1. Disable or remove sessions_yield from all agent/tool allowlists and add it to denies if possible (e.g., via tools.allow, tools.deny, tool profile edits, or via config/project settings).
  2. Restart the gateway (to ensure fresh tool catalog).
  3. Instruct an agent to perform a multi-turn, non-subagent task that would normally use the message tool for interim updates.
  4. Observe (in logs or UI) that the agent sometimes fires sessions_yield anyway—often as an update/heartbeat, even though it was explicitly disabled.
  5. This happens with and without subagents; subagent spawning is not needed to reproduce.

Expected behavior

When sessions_yield is not in the effective tool allowlist (after policy and config resolution), the tool must not be available to agents, and must never appear in the effective tool list, tool catalog, or agent prompt surface. Any attempt to invoke it must error out (not update state or fire the onYield callback).

Actual behavior

Even when disabled by policy, sessions_yield is built and registered with an active callback. Agents can sometimes invoke it (often for a 'status update'), and the call completes successfully. It may show up in the tool list or catalog in some runs, despite config. Filtering and allow/deny logic does not reliably prevent this. This can persist across gateway restarts. Policies and allowlists are ignored.

OpenClaw version

current HEAD (May 2026), commit cc835b6d7 or later

Operating system

Any (reproduced on Linux/macOS)

Install method

dev (pnpm), but install method independent

Model

Any (e.g. Claude, OpenAI, or test backends)

Provider / routing chain

openclaw -> local gateway or direct model proxy; not provider-specific

Additional provider/model setup details

Not provider-specific; tested with default and custom models. Policies set in openclaw.json and/or per-agent settings, both global and agent-specific. No subagents involved.

Logs, screenshots, and evidence

See related logs: agent fires sessions_yield after policy disables it, onYield() invoked, status is yielded. Also confirmed in agent UI where the tool call is surfaced.

Impact and severity

Affected: All agents in restricted-policy contexts Severity: Moderate/High (can break expected coordination, produce unexpected yields) Frequency: Variable (repro typically within 2-3 agent runs with tool filtered) Consequence: Agents 'yield' unexpectedly, requiring user to manually resume, disrupting flow and breaking policy expectations.

Additional information

Root cause: sessions_yield is always created by createOpenClawTools regardless of policy, with the callback attached. Allow/deny filtering happens after the tool and callback are wired up, so the agent can discover and use this tool. Mitigation: Tool must NOT be created at all unless present in the effective tool policy for the session/agent. See also https://github.com/openclaw/openclaw/blob/cc835b6d72765ff81aeab7d8ad8628b425c24547/src/agents/openclaw-tools.ts#L452

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When sessions_yield is not in the effective tool allowlist (after policy and config resolution), the tool must not be available to agents, and must never appear in the effective tool list, tool catalog, or agent prompt surface. Any attempt to invoke it must error out (not update state or fire the onYield callback).

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING