Skip to content

fix: preserve repeated plugin-dir arguments - #1736

Open
aaravxsingh15 wants to merge 1 commit into
anthropics:mainfrom
aaravxsingh15:fix/repeated-plugin-dir-flags
Open

aaravxsingh15 wants to merge 1 commit into
anthropics:mainfrom
aaravxsingh15:fix/repeated-plugin-dir-flags

Conversation

@aaravxsingh15

Copy link
Copy Markdown

Summary

  • add plugin-dir to ACCUMULATING_FLAGS
  • preserve repeated --plugin-dir values instead of keeping only the final value
  • add a focused regression test covering multiple plugin directories

Fixes #1728.

Testing

  • Focused parser suite: 42 passed, 0 failed
  • TypeScript typecheck passed
  • Prettier check passed
  • Full Windows run: 916 passed; remaining failures occurred outside the focused parser suite

@farmer-data

Copy link
Copy Markdown
Contributor

Heads up on a case this may not cover. I applied just the ACCUMULATING_FLAGS change locally against main (a874e9e, agent-sdk 0.3.251) and probed parseSdkOptions:

before:  extraArgs['plugin-dir'] = "./plugin-b"
after:   extraArgs['plugin-dir'] = "./plugin-a�./plugin-b"

Accumulation joins with ACCUMULATE_DELIMITER (\x00), but unlike the other members of that set, nothing unpacks plugin-dir downstream — add-dir splits into additionalDirectories (L210–216), allowedTools/disallowed-tools split at L228–254, mcp-config splits and re-merges at L271–274. So the joined value stays in extraArgs, and the SDK emits one --flag value pair per entry with String(v) and no splitting:

for (let [k, v] of Object.entries(extraArgs))
  if (v === null) argv.push(`--${k}`); else oC(argv, k, v);

Node then refuses the spawn:

ERR_INVALID_ARG_VALUE - The argument 'args[1]' must be a string
without null bytes. Received './plugin-a\x00./plugin-b'

The test asserts toBe("./plugin-a\x00./plugin-b"), which is why CI is green — it pins the joined intermediate rather than the delivered args.

The SDK has a first-class plugins?: SdkPluginConfig[] option (sdk.d.ts:1860) and already emits one --plugin-dir per entry from it, so unpacking there mirrors the add-dir handling. --plugin-dir-no-mcp has the same last-one-wins bug and maps to skipMcpDiscovery.

Happy to share a patch if useful, or leave it with you.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude_args: repeated --plugin-dir collapses to last-one-wins (not in ACCUMULATING_FLAGS), silently dropping plugins

2 participants