Observed since 21 Oct, 09:03 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xkobold/pi-ollama
Ollama extension for pi-coding-agent. Unified local + cloud Ollama support with model management
Ollama integration for pi-coding-agent with accurate model details from /api/show.
deepseek-v4 → 1M tokens, other deepseek → 163,840 tokens (was 4,096). Closes #4.hasReasoningCapability() no longer flags instruct, chat, or code/coder models as reasoning. Only models with actual thinking capability (DeepSeek, R1, QwQ, GPT-OSS, Phi) or a thinking/reason capability from /api/show are marked as reasoning. See Ollama thinking docs.createModel() now sets maxTokens to min(contextWindow, 16384) instead of hardcoded 8192. chat()/chatStream() no longer send max_tokens: 4096 by default — omitted unless explicitly set.:cloud suffix before comparing model names.loadConfigFromSettingsFiles() now uses async dynamic import() instead of require(), fixing ESM compatibility.hasReasoningCapability() accepts optional modelInfo parameter and checks capabilities array for thinking/reason.chat() and chatStream() now throw typed errors: OllamaAuthError (401/403), OllamaRateLimitError (429), OllamaModelError (400/404), OllamaServerError (500/502).chat() and chatStream() now apply a 120s timeout via AbortController.DEFAULT_CONTEXT_LENGTH (131072), DEFAULT_MAX_TOKENS (8192), DEFAULT_REQUEST_TIMEOUT_MS (120000).stripProviderPrefix() now exported and tested./v1 endpoint. Previously, ollama-cloud was registered with baseUrl: "https://ollama.com", causing pi to hit https://ollama.com/chat/completions (HTML homepage) instead of https://ollama.com/v1/chat/completions.cloudUrl config are now properly stripped before appending /v1.# Via pi CLI
pi install npm:@0xkobold/pi-ollama
# Or in pi-config.ts
{
extensions: [
'npm:@0xkobold/pi-ollama'
]
}
# Or temporary (testing)
pi -e npm:@0xkobold/pi-ollama
/api/show for real context lengthcapabilities arraycapabilities and name patterns| Command | Description |
|---|---|
/ollama-status | Check connection status |
/ollama-models | List models with context length |
/ollama-info MODEL | Show model details from /api/show |
/ollama status|info|models | Shortcuts |
The extension uses Ollama's /api/show endpoint to get accurate model information:
curl http://localhost:11434/api/show -d '{
"model": "gemma3",
"verbose": true
}'
Response includes (per Ollama docs):
model_info.<arch>.context_length — Accurate context windowcapabilities — ["completion", "vision", "thinking"]details.parameter_size — "4.3B", "70B", etc.details.family — "gemma3", "llama", etc.Context length is resolved in this order:
model_info.*.context_length — From /api/show (most accurate)context_length, max_position_embeddings, max_sequence_length, n_ctx/api/show| Model Family | Context Length | Source |
|---|---|---|
deepseek-v4 | 1,048,576 (1M) | Ollama library |
kimi | 262,144 (256k) | Ollama library |
qwen3 | 262,144 (256k) | Ollama library |
minimax | 204,800 (200k) | Ollama library |
glm | 202,752 (~198k) | Ollama library |
llama3.1/3.2/3.3 | 128,000 (128k) | Ollama library |
deepseek (non-v4) | 163,840 (160k) | Ollama library |
gpt-oss | 128,000 (128k) | Ollama library |
qwen/qwen2.5 | 32,768 (32k) | Ollama library |
mistral/mixtral | 32,768 (32k) | Ollama library |
llama3 | 8,192 | Ollama library |
| Unknown | 131,072 (128k) | Conservative default per Ollama context docs |
Per Ollama thinking docs, reasoning/thinking is detected by:
capabilities array from /api/show — if it includes "thinking" or "reason"r1 models (word boundary match)instruct, chat, code/coder — these are format tags, NOT reasoningAll HTTP calls classify errors into typed classes:
| Class | Status Codes | Meaning |
|---|---|---|
OllamaAuthError | 401, 403 | Invalid API key |
OllamaRateLimitError | 429 | Rate limit exceeded |
OllamaModelError | 400, 404 | Bad request or model not found |
OllamaServerError | 500, 502 | Server/gateway error |
OllamaError | Other | Catch-all |
Per Ollama error docs.
Configuration is loaded with the following precedence (highest to lowest):
pi.settings (runtime API, when available).pi/settings.json (project-local settings)~/.pi/agent/settings.json (global user settings)export OLLAMA_HOST="http://localhost:11434" # Local base URL
export OLLAMA_HOST_CLOUD="https://ollama.com" # Cloud base URL
export OLLAMA_API_KEY="your-api-key" # Cloud API key
Add to your global settings (~/.pi/agent/settings.json):
{
"ollama": {
"baseUrl": "http://localhost:11434",
"cloudUrl": "https://ollama.com",
"apiKey": "your-ollama-cloud-api-key"
}
}
Per Ollama cloud docs.
import {
fetchModelDetails,
getContextLength,
hasVisionCapability,
hasReasoningCapability,
createClients,
classifyHttpError,
OllamaError,
OllamaAuthError,
OllamaRateLimitError,
OllamaModelError,
OllamaServerError,
DEFAULT_CONTEXT_LENGTH,
DEFAULT_MAX_TOKENS,
} from '@0xkobold/pi-ollama/shared';
// Get model details from local Ollama
const details = await fetchModelDetails(client, 'gemma3');
// Extract context length (with name-based fallback)
const ctx = getContextLength(details, 'gemma3'); // 131072
// Check capabilities
const hasVision = hasVisionCapability(details); // true/false
const hasReasoning = hasReasoningCapability('deepseek-r1', details); // true
// Classify HTTP errors
try {
await chat(client, { model: 'gemma3', messages: [...] });
} catch (err) {
if (err instanceof OllamaRateLimitError) {
// Handle rate limit
} else if (err instanceof OllamaAuthError) {
// Handle auth failure
}
}
MIT © 0xKobold
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@types/bunEnvironment{
"local_name": "@types/bun",
"alias": false,
"peer_metadata": null
} | ^1.3.13 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^6.0.3 | development |
@mariozechner/pi-coding-agentEnvironment{
"local_name": "@mariozechner/pi-coding-agent",
"alias": false,
"peer_metadata": null
} | >=0.65.2 | peer |
@sinclair/typeboxEnvironment{
"local_name": "@sinclair/typebox",
"alias": false,
"peer_metadata": null
} | >=0.32.0 | peer |
ollamaEnvironment{
"local_name": "ollama",
"alias": false,
"peer_metadata": null
} | ^0.6.3 | peer |
Source distribution
{
"integrity": "sha512-OlipLbUYd0p2niqiwGVnxMxFGbOM54BN8OYTt9R/cExlJ5vE7TEGJc5YN0F3yVf3mWKArg/kQppMCNkGro+d0A==",
"shasum": "03d602e55e99cb5ada88065f2056ebdbd422ac3a",
"tarball": "https://registry.npmjs.org/@0xkobold/pi-ollama/-/pi-ollama-0.5.0.tgz",
"fileCount": 10,
"unpackedSize": 82897,
"signatures": [
{
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
"sig": "MEQCIBf6W/HSh5iw+B/RIjA0qeyw7OY45omH3t4tghPwBy66AiBnL4edEwpysccUfmvbYfAkYTKF61gh5qU1C0539bWcvg=="
}
]
}Observed since 21 Oct, 09:03 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:fdf4b61c249d5ed3fc904f94db9afebbbe25b53c1931e3c94c893ecec42475b4