agent-native icon indicating copy to clipboard operation
agent-native copied to clipboard

resources write stores the text true when content starts with -- (every skill with frontmatter)

Open nabilkhan199999 opened this issue 1 month ago • 0 comments

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 createAgentChatPlugin with the built-in resources tool.
  • We do not use custom resource tooling.
  • The same parser code is present in 0.203.0 and 0.178.1.

Steps

  1. Ask the agent to create a skill, for example "create a spell-check skill".
  2. The agent calls resources with action: "write", path: "skills/spell-check/SKILL.md" and content beginning with ---\nname: spell-check\n....
  3. The tool returns Wrote resource: skills/spell-check/SKILL.md (4 bytes).
  4. 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 wrapCliScript is affected when a value starts with --. save-memory goes through the same wrapper and parser.
  • packages/core/src/scripts/dev/index.ts has a second copy of wrapCliScript with the same line.
  • The Resources "+ → Skill" flow and the turn-into-skill skill both tell the agent to write frontmatter-first content with resources, so they appear to be affected too.
  • A leading character before the --- avoids the bug, but parseFrontmatter requires --- at the first character, so the header is then not read.

nabilkhan199999 avatar Oct 07 '26 15:10 nabilkhan199999