2 Commits

Author SHA1 Message Date
Zuyi Zhou
5b8ee65c63
fix(agent): name grok login on a credential refusal (#792)
## Summary

A Grok Build row that fails for want of a credential was told to "sign
in to it and connect again", with no command. Claude Code, Codex, Hermes
and Qwen Code already name the command read from the installed tool.
`grok login --help` on Grok Build 1.0.41 titles that command "Sign in to
Grok", so a credential refusal now says to run `grok login`.

The row launches `grok agent stdio`, a local install, so there is one
spelling and no `npx` fallback. The binary is native, so a launch that
quits is not reported as an old Node.js. A provider status (404, 402,
429) still gets the shared verdict and no in-agent command: none was
measured that fixes a missing model, a missing credit and a rate limit
together.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen --python 3.12 --extra dev ruff check
raven/agent/subagent/presets.py tests/test_subagent_third_party.py
tests/test_subagent_node_runtime.py` and `ruff format --check` on the
same files: clean.
- `uv run --frozen --python 3.12 --extra dev pytest -q
tests/test_subagent_third_party.py::test_grok_login_is_the_one_spelling
tests/test_subagent_third_party.py::test_each_agent_s_fix_is_named_as_data_from_the_one_decision
tests/test_subagent_third_party.py::test_a_row_with_one_spelling_is_not_offered_a_second
tests/test_subagent_node_runtime.py::test_a_launch_that_quit_on_an_old_node_is_named_with_both_versions`:
4 passed.
- Reverting `raven/agent/subagent/presets.py` to `origin/main` makes
`test_grok_login_is_the_one_spelling` fail with `KeyError: 'grok'`. The
Node.js test stays green.
- `python scripts/check_source_language.py origin/main...HEAD`: exit 0.
- `git merge-tree --write-tree HEAD origin/main`: clean. `git diff
--check origin/main...HEAD`: clean.

The full suite, the type checker and a live logged-out `grok agent
stdio` were not run.

- [x] Relevant tests pass locally
- [ ] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

No user-facing doc describes this refusal sentence. The page reads the
remedy the connect path already returns.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

Only a credential-shaped refusal on the `grok` preset gains a command. A
hand-written row that is not that preset is unchanged. Billing, quota, a
missing model and a launch that quits keep the sentences they already
had.

Rollback: revert the squash commit. There is no migration.

## Related Issues

N/A
2026-09-26 10:06:37 +08:00
Handsome-wzw
df77c26d57
fix(*): a Qwen Code on an old Node.js names it, and its model fix runs /auth (#786)
## Summary

Qwen Code is a Node.js script (`#!/usr/bin/env node`), so it runs on
whichever `node` comes first on the PATH it is launched with, not the
one it was installed with. On a machine whose PATH puts an older Node.js
first (an nvm default left on 18, a Homebrew formula nobody upgraded), a
Connect or Test used to end in "Qwen Code quit as soon as it started",
with the reason folded under it as English that names no Node.js at all.

Measured on Qwen Code 0.24.4 with official Node.js builds:

| Node.js on PATH | What qwen does | What the sheet says now |
| --- | --- | --- |
| 18.20.8 | Exits 1 at import: `SyntaxError: The requested module
'node:fs' does not provide an export named 'openAsBlob'` | It needs
Node.js 22 or newer and this machine started it with 18.20.8, plus the
upgrade command when the installer is recognisable |
| 20.20.2 | Runs | Connects, as before |
| 22 | Runs | Connects, as before |

The verdict is read off facts, not off that sentence, which changes with
every release and names no version anyway:

- `raven/agent/subagent/node_runtime.py` (new): resolves the interpreter
from the agent's shebang the way `env` would, on the launch's own PATH
(the row's, else the login shell's), runs `node --version`, and reads
the floor from the agent's own `package.json` `engines.node` (`>=22.0.0`
for qwen). Any missing fact means no verdict, so Node.js is never named
on a guess. The upgrade command is given only where the installer shows
in the path: `nvm install 22 && nvm alias default 22` under
`~/.nvm/versions/node/`, `brew upgrade node` under `Cellar/node/`;
anything else (a pinned `node@18`, an installer package) gets nodejs.org
and no command.
- `presets.py`: `NODE_RUNTIME_PRESETS` holds the presets measured to die
this way, Qwen Code only.
- `probe.py`: a launch that quit is checked only for such a preset, and
only after the `--acp` check; the check runs `node --version`, so
Connect and Test reach it through `asyncio.to_thread`.
- `probe_state.py`, `rpc/models.py`, `rpc-schema/openrpc.json`:
`SubagentRemedy.kind` gains `runtime`, with optional `needs` and `found`
(both sent for `runtime`). Both generated clients were regenerated.
- ui-web: the sheet says both versions and shows the upgrade command on
its own line, or points at nodejs.org when there is none; a `runtime`
remedy that arrives without its versions reads as a launch that quit.
The card says "Qwen Code's Node.js is too old". zh/en strings in
`i18n/messages.json`. The offline fixture library keeps its Qwen Code
row on the two-step model fix, so `needs` and `found` join `UNSENT` with
the reason.

Why the stderr sentence is not the trigger: Raven keeps the last 400
characters of stderr in the error it reports, and the `SyntaxError` line
sits 642 characters from the end of qwen's output, so the Test path
never sees it.

Also in this PR: the fix for a model its provider no longer serves
(404), no credit (402) and a rate limit or spent quota (429) now says
`/auth`, not `/model`. `/model` only picks among the models already
registered in `~/.qwen/settings.json`, and qwen 0.24.4's own OpenRouter
preset registers exactly two free models, both since withdrawn from
OpenRouter's free tier (each answers 404 "unavailable for free",
measured 2026-09-24). So anyone set up the default way was sent to a
list offering only dead models. `/auth` re-runs the provider setup,
whose "Model IDs" step takes any id the provider serves; the sheet's
three sentences now say to enter a working model at that step
(`MODEL_SWITCH_HINTS` in `presets.py`, `gui.agent.fix_model` /
`fix_billing` / `fix_quota`).

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `python -m pytest --idle-ceiling-strict` over every test file that
touches sub-agents, the ACP client or the RPC layer: 6423 passed, 1
failed. The failure is
`tests/test_rpc_files.py::test_a_host_without_libreoffice_says_so`,
which fails the same way on `main` on this machine.
- `tests/test_subagent_node_runtime.py` (new, 13 tests): the verdict,
the installer-specific commands, the floor as declared, an absolute
shebang, every missing fact, Connect through the thread, and Test.
Removing the classification call in `probe.py` fails the three
Connect/Test tests.
- `ruff check raven tests` and `ruff format --check raven tests`: clean.
- `python scripts/coverage_gate.py --coverage-json coverage.json diff
--base-ref origin/main --threshold 90`: 100.00% (120/120 executable
changed lines).
- ui-web: `npm run type-check` clean; `npm run lint` 0 errors (4
existing warnings in files this does not touch); `npm run gen:check` in
sync; `npx vitest run` 3035 passed.
- ui-tui: `npm run lint:rpc` and `npm run lint:i18n` in sync.
- Live, real Qwen Code 0.24.4 through `ping_agent` and `run_test`, with
official Node.js 18.20.8, 20.20.2 and 22 first on the launch PATH: 18
gets `runtime` (needs 22, found 18.20.8) on both buttons within a
second; 20 and 22 connect. The 20 Qwen Code cases from #779 were re-run
and give the same results as before, except that the model and billing
cases now name `/auth`.
- The rendered sheet was checked in a browser against the offline
fixture library, zh, both with and without an upgrade command.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

No user-facing doc describes these refusal messages; the new sentences
live in `i18n/messages.json`.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

The check runs `node --version` on the resolved interpreter, only after
a Qwen Code launch has already quit, and with a 5 s bound, off the event
loop. Nothing is read or sent beyond the agent's own `package.json`.

`runtime`, `needs` and `found` are additive. A page that predates them
drops a kind it does not know and shows its generic "could not connect"
text; a stored verdict carrying them reads back as no remedy on older
code.

Rollback: revert the squash commit; there is no migration.

## Related Issues

N/A

Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
2026-09-24 18:36:57 +08:00