Extensions recieve toolArgs as a string rather than an object
- Dominant language
- No language data
- Stars
- 2.1k
- Forks
- 153
- PR merge metrics
- No merged PRs in 30d
Description
### Short summary
_No response_
### Affected version or release
v1.1.10
### Installation context
downloaded from website, windows-x64
### What happened?
Hi devs, thanks for your hard work!
From my ai chat -
In `onPreToolUse` the host delivers `toolArgs` as a JSON-encoded *string*, but the SDK docs (`agent-author.md`, `examples.md`) show object access (`args.command`, `...input.toolArgs`) and the `.d.ts` types expose it as `unknown`/`JsonValue`. This means all documented object-style examples silently return nothing. Either deliver a parsed object or parse/normalize in the SDK and document the contract explicitly.
### Steps to reproduce
My extension requires this in order to function:
function toolTargets(toolName, args) {
if (!args) return [];
// The RPC layer delivers toolArgs as a JSON-encoded string; parse it to
// an object so we can inspect .path/.paths/.pattern.
if (typeof args === "string") {
try {
args = JSON.parse(args);
} catch {
return [];
}
}
### Expected behavior
I think args should be passed as objects, but at a minimum when the ai references the documents and then writes and extension, it should copy something that works correctly.
### Additional context
_No response_
Contributor guide
Research direction
Start with the onPreToolUse RPC path and the .d.ts types, then compare the documented contract in agent-author.md and examples.md with the string payload described for v1.1.10. Done means the host or SDK contract and documentation consistently explain and support the usable toolArgs shape, including the documented object-style access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100