Skip to content

Separate transport from backend: --backend ollama with interactive model picker#2

Open
wisbech wants to merge 10 commits into
developfrom
feature/backend-separation
Open

Separate transport from backend: --backend ollama with interactive model picker#2
wisbech wants to merge 10 commits into
developfrom
feature/backend-separation

Conversation

@wisbech

@wisbech wisbech commented May 7, 2026

Copy link
Copy Markdown
Owner

What

Separates the concept of transport (CLI agent: pi, opencode, claude, etc.) from backend (where models live: ollama, anthropic API, openai API).

farm launch pi --backend ollama
farm launch opencode --backend ollama --model llama3.1
farm launch claude

How it works

  1. --backend ollama queries GET /api/tags
  2. Shows interactive picker — 10 models displayed, sorted by modified_at (most recent first)
  3. First model marked as [default — latest] — press Enter to accept
  4. Model name + backend saved to ~/.sentinel/config.json
  5. Transport invokes with the selected model

Changes

  • src/config.ts: +backend field on SentinelConfig, +listOllamaModels(), +formatSize(), ollama removed from transports list
  • src/index.ts: --backend flag parsing, pickOllamaModelInteractive() picker, createInvoke dedup fix, help text updated with BACKENDS section

Copilot AI review requested due to automatic review settings May 7, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new --backend concept (starting with ollama) distinct from the selected CLI “transport”, and adds an interactive Ollama model picker that can persist the chosen backend + model into the saved Sentinel configuration.

Changes:

  • Add backend to SentinelConfig and implement listOllamaModels() + formatSize() to discover and present Ollama models.
  • Extend farm launch to parse --backend and, for --backend ollama, run an interactive model picker and save the selected model/backend.
  • Fix createInvoke() to avoid constructing the transport twice and update help text to document the backend option.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/index.ts Parses --backend, adds interactive Ollama model selection, persists backend in config output, and fixes createInvoke() binding.
src/config.ts Adds backend to config schema and adds Ollama model discovery + size formatting helpers; removes Ollama from the transport list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts
Comment on lines +240 to +243
if (options.backend === "ollama") {
const models = await listOllamaModels();
if (models.length === 0) {
console.log("Ollama not reachable or no models found.\nStart Ollama and pull a model: ollama pull llama3.1");
Comment thread src/index.ts Outdated

if (overflow > 0) console.log(`\n ... and ${overflow} more models`);

const choice = await askOptional("Select [1-${displayModels.length}, Enter for default]");
Comment thread src/index.ts
Comment on lines 309 to 314
const arg = args[i];
if (known.includes(arg as TransportType)) transport = arg as TransportType;
else if (arg === "--model" || arg === "-m") options.model = args[++i];
else if (arg === "--backend" || arg === "-b" || arg === "--back") options.backend = args[++i] || "ollama";
else if (arg === "--api-key" || arg === "-k") options.apiKey = args[++i];
else if (arg === "--base-url" || arg === "--url") options.baseUrl = args[++i];
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.

2 participants