fix(integrations): dispatch Amp via execute mode - #4581
hmohammadi wants to merge 1 commit into
Conversation
Fixes github#4580. `AmpIntegration` never overrode `build_exec_args()`, so it inherited `MarkdownIntegration`'s generic `-p <prompt> --model <model> --output-format json`. None of those flags exist in the Amp CLI, so every workflow `command:`/`prompt:` step targeting Amp aborted at argument parsing with `error: unknown option '-p'` before the agent ever ran. Amp's non-interactive entry point is `-x/--execute`, and its structured output flag is `--stream-json` (valid only alongside `--execute`), so this dispatches through those. `model` is deliberately dropped rather than remapped: Amp exposes no model-selection flag. `-m/--mode` takes an agent mode (low/medium/high/ ultra or a plugin mode), not a model identifier, so forwarding the caller's model onto it would silently select the wrong thing. Extra args from `SPECKIT_INTEGRATION_AMP_EXTRA_ARGS` are applied before `--execute` because the flag takes the prompt as an optional inline value; appending between the two would consume the prompt as the operator's flag value. Same fix shape as the one-off overrides for opencode (github#2409) and goose (github#3781). Part of the audit in github#2416. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X8QcZkxX87sSjsfUzBRm9h
|
Following up on the test note in the description — the full
The failing set is identical — same 18 node IDs, verified by diffing the sorted All 18 are symlink tests, failing because this machine (Windows 11, no symlink privilege) cannot create the symlinks they set up — e.g. Targeted results on this branch:
For reference, the whole suite on |
Description
Fixes #4580. Part of the audit in #2416.
AmpIntegrationnever overrodebuild_exec_args(), so it inherited the generic implementation fromMarkdownIntegration(base.py:1062), which emits-p <prompt> --model <model> --output-format json. None of those three flags exist in the Amp CLI, so every workflowcommand:/prompt:step targeting Amp aborted at argument parsing before the agent ran:Amp's non-interactive entry point is
-x/--execute, and its structured-output flag is--stream-json(valid only alongside--execute), so this dispatches through those instead:Verified against
amp --help(v0.0.1789372854-ge954c8):-p <prompt>-x, --execute [message]--model <model>--output-format json--stream-jsonOn
model: it is deliberately dropped rather than remapped. Amp exposes no model-selection flag.-m/--modetakes an agent mode (low/medium/high/ultra, or a plugin mode) which "controls the model, system prompt, and tool selection" — it is not a model identifier, so forwarding the caller's model onto it would silently select the wrong thing. This is the one judgement call in the diff; happy to change it if maintainers prefer a different mapping.On flag order:
SPECKIT_INTEGRATION_AMP_EXTRA_ARGSis applied before--execute, because--execute [message]takes the prompt as an optional inline value — appending between the two would consume the prompt as the operator's flag value.Same fix shape as the existing one-off overrides for opencode (#2409) and goose (#3781); follows the
OpencodeIntegration.build_exec_args()pattern.Testing
uv run specify --helpuv sync && uv run pytestAdded 4 regression tests to
tests/integrations/test_integration_amp.py(previously a stub with nobuild_exec_argscoverage). All 4 fail onmainwith'-p' != '--execute'and pass with this change; the file's 22 tests pass in full.tests/test_agent_config_consistency.py: 28 passed.tests/integrations/test_extra_args.py,test_base.py,test_integration_base_markdown.py— the shared machinery this override calls into (_apply_extra_args_env_var,_resolve_executable, theMarkdownIntegrationbase): 119 passed, 1 skipped.Full-suite context, stated plainly: on this machine (Windows 11, Python 3.14.7)
mainalready reports 182 failed / 7694 passed / 189 skipped before this change. Every failure is environmental — 105 bash/parity and 63 symlink tests, on a box with no symlink privilege — and none are intests/integrations/test_integration_amp.py. Of the 18 baseline failures undertests/integrations, all 18 are symlink tests. A fulltests/integrationsrun against this branch was still in progress at the time of writing; I will post the before/after comparison as a comment when it completes.End-to-end against the real Amp CLI (
npx @sourcegraph/amp, v0.0.1789372854-ge954c8) on Windows 11: the previously generated argv exits 1 at parsing withunknown option '-p', while the argv this PR generates is accepted and proceeds to Amp's device-login prompt (this machine has noAMP_API_KEY, so execution stops there rather than at flag parsing).AI Disclosure
Investigation, patch and tests were written with Claude Code; I reviewed them and ran every command quoted above on my own machine. The Amp flag surface was verified against
amp --helpfrom the installed binary, not from model recall.