#14734: test(agents): guard against stale allowAgents in existing sessions
agents
stale
size: S
Cluster:
Session Management Enhancements
## Problem
Existing sessions could appear to retain stale subagent allowlist behavior after config changes, causing confusion around `agents_list` and `sessions_spawn` outcomes.
## What Changed
- Added regression coverage for `agents_list` to verify allowlist changes are reflected when reusing the same tool/session context.
- Added regression coverage for `sessions_spawn` to verify cross-agent spawn authorization refreshes after allowlist updates in the same session/tool instance.
## Validation
- `pnpm vitest run src/agents/openclaw-tools.agents.test.ts src/agents/openclaw-tools.subagents.sessions-spawn-allows-cross-agent-spawning-configured.test.ts`
- Result: 2 files passed, 8 tests passed.
## Issue
- Closes #13377
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds regression tests to ensure `allowAgents` updates are picked up even when reusing an existing tool instance within the same session context.
- `src/agents/openclaw-tools.agents.test.ts` adds a case that calls `agents_list`, mutates the mocked config, then calls the same tool again and expects the updated allowlist to be reflected.
- `src/agents/openclaw-tools.subagents.sessions-spawn-allows-cross-agent-spawning-configured.test.ts` adds a similar case for `sessions_spawn`, verifying it goes from `forbidden` to `accepted` after allowlist changes without recreating the tool.
These tests align with how the tools are implemented (`agents_list` and `sessions_spawn` call `loadConfig()` inside `execute`), so they protect against future refactors that accidentally cache allowlist state across executions.
<h3>Confidence Score: 4/5</h3>
- This PR is largely safe to merge; changes are test-only and match current tool behavior.
- The added tests are consistent with the production implementation (config is loaded within each tool execution), so they should be stable. The main concern is test isolation: the module-scoped gateway mock in the sessions_spawn test file can leak into other tests depending on the runner’s module cache/execution order.
- src/agents/openclaw-tools.subagents.sessions-spawn-allows-cross-agent-spawning-configured.test.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16964: test: add regression tests for sub-agent session path resolution
by StressTestor · 2026-02-15
84.2%
#11854: fix: resolve per-agent tools.exec config in pi-tools
by Yida-Dev · 2026-02-08
83.0%
#7584: Tests: align subagent announce wait expectations
by justinhuangcode · 2026-02-03
81.4%
#7525: Agents: skip errored tool calls during pairing
by justinhuangcode · 2026-02-02
81.2%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
80.9%
#9583: fix(models): allow models in agents.defaults.models even if not in ...
by hotzen100 · 2026-02-05
80.0%
#15941: fix(sessions): allow session file paths from other agents' sessions...
by LiJianLi128 · 2026-02-14
80.0%
#13412: fix(sessions): refresh allowAgents permissions after gateway restart
by arun-dev-des · 2026-02-10
79.9%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
79.6%
#17788: fix: correct config path in sessions_spawn error hint (v2)
by Limitless2023 · 2026-02-16
79.5%