Skip to content

Comments

daemon: Support CLI models in chat and agent endpoints#109

Open
jetm wants to merge 1 commit intosteipete:mainfrom
jetm:daemon-cli-transport
Open

daemon: Support CLI models in chat and agent endpoints#109
jetm wants to merge 1 commit intosteipete:mainfrom
jetm:daemon-cli-transport

Conversation

@jetm
Copy link

@jetm jetm commented Feb 21, 2026

Summary

  • Route CLI-transport model selections (e.g., cli/claude) through runCliModel() in both the chat and agent daemon endpoints, instead of rejecting them
  • During auto-model selection, API-key-based providers are still preferred; CLI is used as fallback when no key-authenticated option is available
  • Flatten multi-turn conversation history into a single text prompt for CLI models (they don't support structured message APIs)
  • Fix parseJsonFromOutput to handle CLI providers (Claude Code ≥2.x) that emit a JSON array instead of a single object or JSONL, extracting the type: "result" entry

Motivation

The daemon rejected any request that resolved to a CLI-transport model, forcing users to have API keys configured even when a local CLI binary (e.g., claude) was available. This made the daemon unusable for users who only have a Claude subscription (no API credits) or who prefer using their local CLI session.

Test plan

  • pnpm build succeeds
  • /v1/models lists cli/claude when the binary is available
  • POST /v1/agent with model: "cli/claude" returns correct summarization via JSON response
  • POST /v1/agent with model: "cli/claude" returns correct SSE events (chunk → assistant → done)
  • Systemd service starts and serves requests correctly
  • Browser extension successfully summarizes pages using CLI: Claude model

The daemon rejected any request that resolved to a CLI-transport model,
throwing immediately rather than attempting to fulfill the request. This
forced users to have API keys configured even when a local CLI model
was available, making the daemon unusable in environments without cloud
credentials.

Route CLI-transport model selections through runCliModel() in both the
chat and agent code paths. During auto-model selection, API-key-based
providers are still preferred; CLI is only used as a last resort when
no key-authenticated option is available. Conversation history is
serialized into a flat system-prompt-plus-turns string, since CLI
models do not expose a structured message API. Also fix the CLI output
parser to handle providers that emit a JSON array rather than a
top-level object, extracting the entry whose type field is "result".

Signed-off-by: Javier Tia <floss@jetm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant