fix: add --system-prompt and --tools CLI flags to add harness#1098
fix: add --system-prompt and --tools CLI flags to add harness#1098
Conversation
These options existed in AddHarnessOptions and were handled by the add() method and TUI wizard, but were never registered as Commander .option() declarations in registerCommands(). This caused the documented CLI flags (per the DevGuide) to silently fail on `agentcore add harness`. Adds the missing CLI option registrations for: - --system-prompt, --tools, --mcp-name, --mcp-url - --gateway-arn, --gateway-outbound-auth, --gateway-provider-arn, --gateway-scopes Also adds type annotations in the action handler, pass-through mapping to this.add(), and unit tests for the tools code path.
|
The new CLI flags expose several silent-failure paths that didn't matter before because the TUI wizard enforced required follow-up fields, but now become user-visible footguns. In
Since these flags are being added specifically because the DevGuide documents them and customers are hitting errors, a user who follows the docs and mistypes one related flag will get a harness created with A few options to fix:
Worth adding tests for at least the error paths ( |
Coverage Report
|
Without validation, missing companion flags (e.g. --tools remote_mcp without --mcp-url) cause tools to be silently dropped from harness.json. Validates: unknown tool names, required companion flags for remote_mcp (--mcp-name, --mcp-url) and agentcore_gateway (--gateway-arn), invalid --gateway-outbound-auth values, and required oauth fields (--gateway-provider-arn, --gateway-scopes).
Summary
--system-prompt,--tools,--mcp-name,--mcp-url,--gateway-arn,--gateway-outbound-auth,--gateway-provider-arn, and--gateway-scopesCLI option declarations toagentcore add harnessthis.add()validateAddHarnessOptionsto reject unknown tool names, missing companion flags, and invalid enum values — prevents silent tool omissionContext
The
AddHarnessOptionsinterface andadd()method have supportedsystemPrompt,selectedTools,mcpName,mcpUrl,gatewayArn, and the gateway outbound auth fields since they were introduced, and the TUI wizard correctly collects and passes them. However, the Commander.option()registrations inregisterCommands()were never added, so these flags silently fail when passed via CLI.The DevGuide documentation references
--system-promptand--toolsonagentcore add harness, causing errors for customers using the preview release.The
agentcore invokecommand already has both--system-promptand--toolsflags — this fix bringsagentcore add harnessto parity.Verified that these flags were never present in any version of
HarnessPrimitive.tson the preview branch (checked all 9 commits that touched the file) — this is not a regression, but a gap from initial implementation.Validation
The tool-building logic in
add()uses guarded branches that silently drop tools when companion flags are missing (e.g.remote_mcpwithout--mcp-url). Since these flags are being added specifically because docs reference them, a typo or missing flag would create a harness withtools: []and no error — worse than the current "unknown flag" error.Added validation in
validateAddHarnessOptions(consistent with existing patterns like JWT auth validation):remote_mcpwithout--mcp-nameor--mcp-url→ erroragentcore_gatewaywithout--gateway-arn→ error--gateway-outbound-authvalue → error listing valid optionsoauthauth without--gateway-provider-arnor--gateway-scopes→ errorTest plan
npm run typecheckpassesnpm run lintpasses (0 errors)npm run format:checkpassesagentcore add harness --name test --system-prompt "You are a coding assistant" --tools agentcore_browser,agentcore_code_interpreter