cli-shim: hermes model picker + runtime-resolver fix (builds on #26634) - #36084
Closed
Radu-Podila wants to merge 11 commits into
Closed
cli-shim: hermes model picker + runtime-resolver fix (builds on #26634)#36084Radu-Podila wants to merge 11 commits into
Radu-Podila wants to merge 11 commits into
Conversation
…PT-account model fix
Hermes agent loop calls create(stream=True) for most turns and iterates the result with 'for chunk in stream'. Previously the shim ignored stream= and returned the whole SimpleNamespace response, causing 'types.SimpleNamespace object is not iterable' downstream. Now emit OpenAI-shaped chunks: one content delta, one per tool_call, and a final chunk with finish_reason + usage. CLIs don't support per-token streaming so each chunk carries the full payload. This was the root cause of fleet-wide cli-shim failures after the provider was wired up.
# Conflicts: # run_agent.py
cli-shim was excluded from the model picker because external_process auth was skipped in the auto-inject list (non-api-key flows were left as an open question in the RFC). This adds the missing picker UX: - exempt cli-shim from the external_process auto-inject skip (models.py) - add _model_flow_cli_shim (main.py): a no-API-key selection flow that lets the user pick among the profile's CLI model aliases and persists provider=cli-shim - give the profile a display_name/description so the picker row reads well Now `hermes model` -> "CLI shim (claude/codex/gemini)" sets model.provider=cli-shim plus the chosen alias, no config.yaml hand-editing.
…eway path) cli-shim wired up resolve_provider_client (client construction) but not resolve_runtime_provider, which the TUI/gateway use via _ensure_runtime_credentials to resolve credentials before building the client. With provider=cli-shim the resolver fell through every named branch to the API-key fallback, returned no key/base_url, defaulted resolved_provider to openrouter, and bailed with: "Provider resolver returned an empty API key. Set OPENROUTER_API_KEY" Add a cli-shim branch mirroring copilot-acp: base_url=cli://shim, api_key=cli-shim placeholder, api_mode=chat_completions. The marker base_url then routes client creation to CliShimClient as intended.
Pins both fixes: - resolve_runtime_provider(requested="cli-shim") returns cli-shim / cli://shim / cli-shim and does NOT fall back to openrouter (regression test for the empty-API-key abort). - cli-shim is surfaced in CANONICAL_PROVIDERS with a sensible picker label, and the profile reports external_process auth + its CLI model aliases.
…errors there)
A non-zero exit was reported as "CLI 'x' exited N: <stderr>", but Claude Code
prints fatal errors to stdout, not stderr — so the message was blank
("exited 1:") and the cause invisible. Include the stdout tail (preferring
stderr) in both _run_print and _run_codex_exec.
Contributor
|
Thanks for the substantial work wiring the CLI-backed provider through runtime resolution and the model picker. This automated hermes-sweeper review is closing this under the standing in-tree provider-integration policy.
Closed as not-planned per standing maintainer policy ( |
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.
What does this PR do?
Builds on #26634 (the
cli-shimlocal-CLI model provider) and makes it workend-to-end. Two gaps in the original draft prevented
cli-shimfrom beingusable: it couldn't be selected from the UI, and selecting it in config made
the agent crash at startup. This PR fixes both. Full credit for the cli-shim
feature itself goes to the author of #26634 — those commits are carried
unchanged; this PR only adds the two fixes on top.
Related Issue
Builds on / depends on #26634 (no separate issue filed).
Type of Change
Changes Made
hermes_cli/runtime_provider.py— add acli-shimbranch inresolve_runtime_provider(mirrorscopilot-acp). feat(providers): cli-shim — shell out to claude/codex/gemini CLIs via OAuth (RFC) #26634 wiredresolve_provider_clientbut not this path, so the TUI/gateway fell throughto the API-key fallback, defaulted the provider to
openrouter, and abortedwith "Provider resolver returned an empty API key". Now returns
base_url=cli://shim,api_key=cli-shim(placeholder),api_mode=chat_completions.hermes_cli/models.py— exempt cli-shim from theexternal_processauto-inject skip so it appears in the
hermes modelpicker.hermes_cli/main.py— add_model_flow_cli_shim, a no-API-key selectionflow that lists the profile's CLI model aliases and persists
provider: cli-shim.plugins/model-providers/cli-shim/__init__.py— adddisplay_name/descriptionso the picker row reads sensibly.How to Test
claudeCLI on the host (echo hi | claude --print --model sonnet).hermes model→ select "CLI shim (claude/codex/gemini)" → pickclaude-sonnet-cli. Confirm it writesmodel.provider: cli-shimto config.yaml.claude --printwith no API key, instead of erroring at provider resolution.
python -c "from hermes_cli.runtime_provider import resolve_runtime_provider as r; print(r(requested='cli-shim'))"→
provider/base_url/api_key = cli-shim / cli://shim / cli-shim.Checklist
Code
feat(cli-shim):,fix(cli-shim):)pytest tests/ -qand all tests passDocumentation & Housekeeping
CLI_SHIM_PROPOSAL.md, from feat(providers): cli-shim — shell out to claude/codex/gemini CLIs via OAuth (RFC) #26634) unchangedmodel.provider/model.default)Screenshots / Logs
Before (provider: cli-shim, on #26634 alone):
After: agent initializes on
cli-shimand answers viaclaude --printwith no API key.