#14472: fix(skills): map command-dispatch tool args to primary required param (#14326)
stale
size: S
Cluster:
Tool and Plugin Enhancements
## Summary
Fixes #14326
## Problem
When a skill exposes a tool whose primary required parameter is not named `command` (e.g. `sessions_spawn` uses `prompt`), the command-dispatch path passes `rawArgs` only as `args.command`. The tool receives an empty primary param and fails silently or produces wrong results.
## Fix
Add `resolveToolPrimaryArgKey()` that inspects the tool's JSON schema to find the first required string parameter. When dispatching, map `rawArgs` to that key instead of always using `command`.
## Reproduction & Verification
### Before fix (main branch) — Bug confirmed:
- No test file `get-reply-inline-actions-dispatch.test.ts` exists on main.
- `rawArgs` is always mapped to `args.command`, ignoring the tool schema's actual required parameter name.
### After fix — All verified:
```
✓ resolveToolPrimaryArgKey > returns first required string param from sessions_spawn schema (#14326)
✓ resolveToolPrimaryArgKey > returns null when tool has no parameters
✓ resolveToolPrimaryArgKey > returns null when no required params exist
✓ resolveToolPrimaryArgKey > returns first required param even if not string type
✓ resolveToolPrimaryArgKey > prefers first required string over non-string required
✓ resolveToolPrimaryArgKey > returns 'command' when command is the first required string
✓ command-dispatch tool arg mapping > maps rawArgs to primary arg key when different from 'command'
✓ command-dispatch tool arg mapping > does not duplicate when primary arg key is 'command'
8 tests pass (pnpm vitest run src/auto-reply/reply/get-reply-inline-actions-dispatch.test.ts)
```
## Testing
- ✅ 8 tests pass (`pnpm vitest run src/auto-reply/reply/get-reply-inline-actions-dispatch.test.ts`)
- ✅ Lint passes
Most Similar PRs
#23758: Skills: gate deterministic dispatch with allowTools
by bmendonca3 · 2026-02-22
65.4%
#23383: Skills: gate command-dispatch tool targets and args
by bmendonca3 · 2026-02-22
64.1%
#23743: Auto-reply: enforce tools.allow/tools.deny on deterministic skill t...
by bmendonca3 · 2026-02-22
64.1%
#19422: fix: pass session context to plugin tool hooks in toToolDefinitions
by namabile · 2026-02-17
62.3%
#11440: fix: preserve multi-line input for skill commands
by RonanCodes · 2026-02-07
61.6%
#19394: fix(agents): normalize tool call arguments dropped to {} (#19261)
by DevvGwardo · 2026-02-17
60.5%
#14464: fix(hooks): use configured primary model for slug generation (#14272)
by lailoo · 2026-02-12
60.5%
#19679: fix: handle optional sessionKey in subagent-announce test mock
by 88plug · 2026-02-18
60.2%
#3247: [Bug]: Fix session_status tool validation when called with no argum...
by lewiscutey · 2026-01-28
60.0%
#22198: fix(skills): treat empty allowBundled array as block-all
by haitao-sjsu · 2026-02-20
59.9%