daemon: Support CLI models in chat and agent endpoints#109
Open
jetm wants to merge 1 commit intosteipete:mainfrom
Open
daemon: Support CLI models in chat and agent endpoints#109jetm wants to merge 1 commit intosteipete:mainfrom
jetm wants to merge 1 commit intosteipete:mainfrom
Conversation
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>
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
cli/claude) throughrunCliModel()in both the chat and agent daemon endpoints, instead of rejecting themparseJsonFromOutputto handle CLI providers (Claude Code ≥2.x) that emit a JSON array instead of a single object or JSONL, extracting thetype: "result"entryMotivation
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 buildsucceeds/v1/modelslistscli/claudewhen the binary is availablePOST /v1/agentwithmodel: "cli/claude"returns correct summarization via JSON responsePOST /v1/agentwithmodel: "cli/claude"returns correct SSE events (chunk → assistant → done)