resources write stores the text true when content starts with -- (every skill with frontmatter)
Summary
When the agent saves a file through the resources tool and the content starts with --, the stored file contains the four characters true instead of the content. A SKILL.md starts with --- frontmatter, so the agent cannot save a valid skill through this tool. The tool reports success.
Environment
- App: Agent Native Content
@agent-native/core:0.201.1@agent-native/toolkit:0.201.1- We use
createAgentChatPluginwith the built-inresourcestool. - We do not use custom resource tooling.
- The same parser code is present in
0.203.0and0.178.1.
Steps
- Ask the agent to create a skill, for example "create a spell-check skill".
- The agent calls
resourceswithaction: "write",path: "skills/spell-check/SKILL.md"andcontentbeginning with---\nname: spell-check\n.... - The tool returns
Wrote resource: skills/spell-check/SKILL.md (4 bytes). - Open the file. Its content is
true.
Expected
The file contains the content the agent sent.
Actual
The file contains true. The frontmatter and body are discarded, and nothing reports an error.
Cause
wrapCliScript in packages/core/src/server/agent-chat/script-entries.ts turns each tool argument into two CLI arguments:
cliArgs.push(`--${k}`, value);
parseArgs in packages/core/src/scripts/parse-args.ts then treats a value that starts with -- as the next flag, and sets the preceding key to "true":
if (next !== undefined && !next.startsWith("--")) {
result[key] = next;
i++;
} else {
result[key] = "true";
}
Minimal reproduction:
parseArgs([
"--path", "skills/x/SKILL.md",
"--content", "---\nname: x\ndescription: y\n---\n# X",
]).content;
// => "true"
Content that does not start with -- is stored correctly, including content that starts with a single -.
Scope
- Any tool built on
wrapCliScriptis affected when a value starts with--.save-memorygoes through the same wrapper and parser. packages/core/src/scripts/dev/index.tshas a second copy ofwrapCliScriptwith the same line.- The Resources "+ → Skill" flow and the
turn-into-skillskill both tell the agent to write frontmatter-first content withresources, so they appear to be affected too. - A leading character before the
---avoids the bug, butparseFrontmatterrequires---at the first character, so the header is then not read.