hackagent.models.completions.cli
Native Model base for agents driven through a locally installed CLI.
A CLI agent (Claude Code, Codex, Hermes) serves no HTTP endpoint. Each
instance registers a per-instance :class:litellm.CustomLLM handler under a
unique provider name whose completion shells out to the CLI, so the call
still flows through litellm.completion and comes back as a
:class:ModelResponse like every other backend.
Subclasses set the class attributes, read their own options in
:meth:_configure, and build the CLI handler in :meth:_build_handler.
CLIConfigurationError Objects
class CLIConfigurationError(Exception)
A CLI backend was configured wrongly (missing binary, model, litellm).
CLIInteractionError Objects
class CLIInteractionError(Exception)
A CLI backend failed while producing a response (timeout, bad exit).
last_user_text
def last_user_text(messages: List[Dict[str, Any]]) -> Optional[str]
Return the text of the last user message in messages.
is_ollama_launcher
def is_ollama_launcher(binary: str) -> bool
Whether binary is Ollama, which starts an agent with ollama launch.
Only the executable's name counts, so an agent installed under a folder
called ollama still runs natively.
SubprocessCLIModel Objects
class SubprocessCLIModel(Model)
A :class:Model that answers each turn by running a local CLI.
LABEL
Human-readable product name used in messages ("Claude Code").
PROVIDER_PREFIX
Prefix of the per-instance LiteLLM provider name.
DEFAULT_BINARY
Executable looked up on PATH when no binary is configured.
INSTALL_HINT
How to install the CLI, shown when the binary is missing.
DEFAULT_TIMEOUT
Default per-turn timeout in seconds.
LITELLM_API_KEY
API key passed to LiteLLM; the CLIs handle their own authentication.