Skip to content

fix(agents): re-expose toolsAllow core tools in embedded runs - #60842

Closed
ricoyudog wants to merge 1 commit into
openclaw:mainfrom
ricoyudog:fix/cron-tools-allow
Closed

ricoyudog wants to merge 1 commit into
openclaw:mainfrom
ricoyudog:fix/cron-tools-allow

Conversation

@ricoyudog

Copy link
Copy Markdown

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: embedded runs only post-filtered toolsAllow after createOpenClawCodingTools, so restrictive config allowlists could remove exec/read/write before toolsAllow had any effect.
  • Why it matters: cron/isolated runs with toolsAllow: ["exec"] still lost exec under configs like tools.allow: ["group:openclaw"], breaking workflows that depended on explicit per-run tool exposure.
  • What changed: runEmbeddedAttempt now forwards toolsAllow into createOpenClawCodingTools, and the tool policy merge re-exposes explicitly requested core tools through restrictive config allowlists without overriding deny.
  • What did NOT change (scope boundary): this does not bypass explicit deny, sandbox/group/subagent tool policies, or provider/runtime capability gating.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: runEmbeddedAttempt only did a final .filter() against toolsAllow, but createOpenClawCodingTools had already applied config-driven allowlists. Once the policy pipeline filtered a core tool out, the later post-filter could not re-add it.
  • Missing detection / guardrail: there was no regression test covering toolsAllow under a restrictive config allowlist such as group:openclaw.
  • Contributing context (if known): group:openclaw intentionally excludes exec, process, read, write, and edit, so the bug is deterministic under configs that rely on that group and then expect toolsAllow to re-expose a core tool for a specific run.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/pi-tools-agent-config.test.ts, src/agents/pi-embedded-runner/run/attempt.memory-flush-forwarding.test.ts
  • Scenario the test should lock in: restrictive config allowlists still permit explicitly requested core tools for that embedded run, while explicit deny continues to win.
  • Why this is the smallest reliable guardrail: one test pins the effective tool inventory after policy application, and the other pins the runEmbeddedAttempt -> createOpenClawCodingTools forwarding seam.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Embedded runs that set toolsAllow can now re-expose the requested core tools (exec, read, write, etc.) even when a restrictive config allowlist would otherwise hide them. Explicit deny still wins.

Diagram (if applicable)

Before:
[embedded run with toolsAllow=[exec]] -> [createOpenClawCodingTools applies config allowlist] -> [exec removed] -> [post-filter keeps missing set] -> [cron run still has no exec]

After:
[embedded run with toolsAllow=[exec]] -> [forceAllowTools merged into restrictive config allowlists] -> [exec survives policy pipeline unless denied] -> [post-filter selects exec] -> [cron run gets exec]

Security Impact (required)

  • New permissions/capabilities? Yes
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? Yes
  • Data access scope changed? Yes
  • If any Yes, explain risk + mitigation:
    The PR allows an embedded run to re-expose explicitly requested core tools through restrictive config allowlists. Mitigation: the re-exposure is limited to named core tools for that run, explicit deny still wins, and sandbox/group/subagent/provider/runtime restrictions still apply.

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local source checkout
  • Model/provider: policy regression is model-agnostic; forwarding seam verified with openai/gpt-5.4
  • Integration/channel (if any): embedded runner / cron-style tool exposure
  • Relevant config (redacted): tools.profile: "full", tools.allow: ["group:openclaw"]

Steps

  1. Configure a restrictive core-tool allowlist such as tools.allow: ["group:openclaw"].
  2. Run an embedded attempt with toolsAllow: ["exec"].
  3. Inspect the effective tool set.

Expected

  • The effective tool set contains exec for that run unless a stronger deny/runtime restriction blocks it.

Actual

  • Before this fix, exec was missing because it had already been filtered out before toolsAllow was applied.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: targeted regression tests for restrictive allowlist re-exposure and explicit-deny precedence; full attempt.memory-flush-forwarding test file; pnpm check; pnpm build.
  • Edge cases checked: allow-all semantics are preserved, explicit deny still blocks forced tools, and only known core tool ids are re-exposed.
  • What you did not verify: I did not run a live end-to-end cron job against a local gateway build from this branch.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: a per-run toolsAllow request could unintentionally widen a restrictive config allowlist too broadly.
    • Mitigation: the merge only applies to explicitly requested known core tools, and allow-all / deny semantics are preserved.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 4, 2026
@greptile-apps

greptile-apps Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a two-phase tool-policy bug in embedded runs: createOpenClawCodingTools was applying config-level allowlists (e.g. group:openclaw) before toolsAllow had any chance to re-expose core tools, so the post-filter in runEmbeddedAttempt could never recover a tool that the policy pipeline had already dropped. The fix threads toolsAllow as forceAllowTools into createOpenClawCodingTools, where it is normalised to known core IDs and merged into each config-level policy via the new mergeForceAllowPolicy helper before the pipeline runs. Explicit deny, group, sandbox, and subagent policies are intentionally unaffected.

Confidence Score: 5/5

Safe to merge — fix is narrowly scoped, deny-wins is preserved, and key regression cases are covered.

No P0 or P1 findings. mergeForceAllowPolicy correctly skips policies with no allowlist or a wildcard, so allow-all semantics are preserved. The force-allow is filtered to isKnownCoreToolId before being applied, limiting the exposure surface. The two-phase approach (force-allow inside the pipeline, post-filter afterwards) is consistent and correct. Tests cover the restrictive-allowlist re-exposure and deny-precedence paths.

No files require special attention.

Reviews (1): Last reviewed commit: "Agents: re-expose force-allowed core too..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 29, 2026, 12:15 AM ET / 04:15 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +41, Tests +76. Total +117 across 5 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Not assessed.
Failure reason: timeout.

This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict.
Keep any merge decision on the normal maintainer review path until ClawSweeper can complete a fresh review.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against dd6143f60c24.

Label changes

Label changes:

  • remove P2: Current review triage priority is none.
  • remove rating: 🦪 silver shellfish: Current review failed before PR readiness was assessed, so no rating label should remain.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.
Evidence reviewed

PR surface:

Source +41, Tests +76. Total +117 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 57 16 +41
Tests 2 77 1 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 134 17 +117

What I checked:

  • failure reason: timeout.
  • codex failure detail: Codex review failed for this PR: Codex process timed out after 1199999ms.
  • codex stderr: No stderr captured.
  • codex stdout: \n- A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.\n- PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.\n- Maintainers can also comment @clawsweeper review to request a fresh review only.\n- Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.\n- Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.\n- Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.\n\n
\n\n<!-- clawsweeper-security:security-sensitive item=60842 sha=781130b95dd53f947118500.
  • process error code: ETIMEDOUT.
  • Likely related people:

    • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    @clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 19, 2026
    @openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 19, 2026
    @clawsweeper

    clawsweeper Bot commented May 20, 2026

    Copy link
    Copy Markdown
    Contributor

    ClawSweeper PR egg

    🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

    Where did the egg go?
    • The egg game starts only after the PR passes the real-behavior proof check.
    • Before that, no creature or rarity is rolled. The treat waits for real proof.
    • This is still just collectible flavor: proof affects review readiness, not creature quality.

    @openclaw-barnacle

    Copy link
    Copy Markdown

    This pull request has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

    @openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 10, 2026
    @clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
    @openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 15, 2026
    @clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 16, 2026
    @clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 18, 2026
    @clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 29, 2026
    @openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 29, 2026
    @clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 29, 2026
    @steipete

    steipete commented Jul 9, 2026

    Copy link
    Copy Markdown
    Contributor

    Thanks for the contribution. I’m closing this stale PR because the latest review rated the current branch F: it still lacks the requested real-behavior proof or merge-ready branch shape, and there has been no human follow-up after the review. A fresh, focused PR against current main with the requested proof is welcome.

    @steipete steipete closed this Jul 9, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    [Bug]: toolsAllow cannot re-expose core tools in embedded cron runs

    2 participants