Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@czekaj
Copy link
Contributor

@czekaj czekaj commented Jan 22, 2026

Summary

  • Fix exec allowlist not matching entries in agents.main when triggered via chat/Discord
  • When createExecTool was called without explicit agentId (e.g., from bash-command.ts), the allowlist lookup used "default" instead of deriving the agent from sessionKey
  • User's allowlist entries in agents.main were never matched, causing repeated approval prompts

Root Cause

In bash-command.ts:333, createExecTool was called with sessionKey but NOT agentId:

const execTool = createExecTool({
  scopeKey: CHAT_BASH_SCOPE_KEY,
  sessionKey: params.sessionKey,  // ← sessionKey passed
  // agentId NOT passed!
});

In bash-tools.exec.ts, the allowlist lookup used defaults?.agentId:

const approvals = resolveExecApprovals(defaults?.agentId, ...);

With agentId undefined, resolveExecApprovalsFromFile fell back to:

const agentKey = params.agentId ?? "default";

This looked up agents.default instead of agents.main, missing all user allowlist entries.

Fix

Derive agentId from sessionKey if not explicitly provided:

const agentId = defaults?.agentId ?? resolveAgentIdFromSessionKey(defaults?.sessionKey);

Then use the derived agentId in all allowlist operations.

Test plan

  • pnpm test src/agents/bash-tools.test.ts passes (16 tests)
  • pnpm test src/infra/exec-approvals.test.ts passes (15 tests)
  • Manual test: trigger exec from Discord with allowlist entries in agents.main

🤖 Generated with Claude Code

@czekaj czekaj marked this pull request as draft January 22, 2026 03:02
@steipete steipete self-assigned this Jan 22, 2026
@steipete steipete marked this pull request as ready for review January 22, 2026 03:58
czekaj and others added 2 commits January 22, 2026 03:58
When creating exec tools via chat/Discord, agentId was not passed,
causing allowlist lookup to use 'default' key instead of 'main'.
User's allowlist entries in agents.main were never matched.

Now derives agentId from sessionKey if not explicitly provided,
ensuring correct allowlist lookup for all exec paths.
@steipete steipete force-pushed the fix/exec-allowlist-agentid-derivation branch from 74a66ae to 2d583e8 Compare January 22, 2026 04:00
@steipete steipete merged commit 3b2aff0 into openclaw:main Jan 22, 2026
37 of 42 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 2d583e8\n- Merge commit: 3b2aff0\n\nThanks @czekaj!

czekaj added a commit to czekaj/clawdbot that referenced this pull request Jan 22, 2026
The node host path was always prompting for approval on-miss, even when
the command was in the allowlist. This mirrors the gateway host behavior
by checking matchAllowlist() and isSafeBinUsage() before deciding to ask.

Also fixes a regression from openclaw#1417 where null was passed instead of
undefined for optional approval request params (resolvedPath, sessionKey),
which caused validation failures.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
czekaj added a commit to czekaj/clawdbot that referenced this pull request Jan 22, 2026
The node host path was always prompting for approval on-miss, even when
the command was in the allowlist. This mirrors the gateway host behavior
by checking matchAllowlist() and isSafeBinUsage() before deciding to ask.

Also fixes a regression from openclaw#1417 where null was passed instead of
undefined for optional approval request params (resolvedPath, sessionKey),
which caused validation failures.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants