fix(QUA-576): route -p and positional args through configured cliAgent#102
Closed
Desperado wants to merge 1 commit into
Closed
fix(QUA-576): route -p and positional args through configured cliAgent#102Desperado wants to merge 1 commit into
Desperado wants to merge 1 commit into
Conversation
Before this change, both `qmax-code -p "..."` and `qmax-code "..."` called `ag.Run` (the Anthropic API agent) unconditionally — silently ignoring `backend=cc` and `backend=codex`. Every CI / scripting / cloud-session invocation bypassed the cc backend and hit the Anthropic API directly (often producing a 401 from a stale keychain key, masking the real issue). The doc claims that the cc backend needs no Anthropic API key were also false for these paths. The fix introduces a single `runOneShot` dispatcher shared by both non-interactive entry points: if `cliAgent` is configured, prompts go through it (claude/codex CLI) with its own streaming output; only when there is no CLI backend do we fall back to `ag.Run`. Regression tests (main_oneshot_test.go) mirror the dispatch contract with a fake CLIAgent and assert (1) CLI takes precedence, (2) API is used as the fallback, (3) CLI errors propagate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
✅ QualityMax Pipeline
Powered by QualityMax — AI-Powered Test Automation |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes QUA-576.
Before this change, both non-interactive entry paths in
main.gocalledag.Run(the Anthropic API agent) unconditionally — silently ignoringbackend=cc(andbackend=codex). Every CI / scripting / cloud-session invocation that usedqmax-code -p "..."orqmax-code "..."was bypassing the cc backend and hitting the Anthropic API directly.Repro (pre-fix)
The 401 comes from a stale keychain key being sent to Anthropic — not from any actual CC backend invocation.
Repro (post-fix)
Fix
runOneShotdispatcher shared by both-pand positional-arg modes.cliAgentis set (cc/codex), the prompt goes through it (cliAgent.Run) with its own streaming output via a Terminal created on demand.cliAgentis nil, fall back toag.Runexactly as before.This also restores doc-comment accuracy: README/CONTRIBUTING/
cc_agent.goall claim "no Anthropic API key needed when backend=cc" — that statement is now true for non-interactive mode, not just the REPL.Tests
main_oneshot_test.go(new) — fakeCLIAgent + 3 assertions:go test ./... -short -count=1.Test plan
qmax-code -backend cc -p "..."returns through claude, no Anthropic 401.qmax-code -backend cc "..."(positional) same behaviour.qmax-code -backend api -p "..."still uses the API path (or errors cleanly if no key).qmax-code -backend codex -p "..."routes through codex CLI.qmax-code -pnow actually use the configured backend.🤖 Generated with Claude Code