Skip to content

Instantly share code, notes, and snippets.

View ThiagoEvoa's full-sized avatar
🏠
Working from home

Evoá ThiagoEvoa

🏠
Working from home
View GitHub Profile
@ThiagoEvoa
ThiagoEvoa / opencode.jsonc
Created September 26, 2026 18:49
OpenCode opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"model": "ollama/qwen2.5-coder:7b",
"provider": {
@ThiagoEvoa
ThiagoEvoa / models.json
Last active September 27, 2026 09:46
PI Agent models.json
{
"providers": {
"ollama": {
"name": "Local Ollama",
"baseUrl": "http://localhost:11434/v1",
"apiKey": "ollama",
"api": "openai-completions",
"authHeader": false,
"headers": {},
"models": [
@ThiagoEvoa
ThiagoEvoa / scratch_qwen_reference.md
Last active November 4, 2026 00:10
Pi Agent Model Configuration Reference: qwen3.8:27b-mlx

Model Configuration Reference: qwen3.8:27b-mlx (Pi Agent & OpenCode)

A comprehensive reference and side-by-side configuration guide for deploying the qwen3.8:27b-mlx model across both Pi Agent (~/.pi/agent/models.json) and OpenCode (~/.config/opencode/opencode.jsonc) agent harnesses.


1. Quick Harness Configuration Snippets

A. Pi Agent Harness (~/.pi/agent/models.json)

Complete Headless Ollama Optimization Guide for Apple Silicon (M3 to M5)

High-Performance Inference Server for Qwen3.8 & Qwen3.6 (16 GB to 512 GB Unified Memory)

A complete, production-grade guide for configuring a dedicated headless Apple Silicon Mac (M3, M4, and M5 generations) using Ollama. This setup is 100% agent-agnostic, serving a high-speed OpenAI-compatible API (/v1) for any client, coding assistant, or agent framework.


Table of Contents

  1. The Headless Architecture Advantage
  2. Ollama Maximum Performance Environment Variables

Universal LLM Context & Output Limits Reference Guide

A comprehensive, hardware-agnostic reference guide for configuring Large Language Model (LLM) context windows, output limits, Key-Value (KV) cache memory footprints, compaction strategies, and agent token budgets across Pi Agent, OpenCode, Ollama, and llama.cpp/vLLM.


1. Core Concepts: context vs output vs prompt

Every LLM request operates inside a finite token budget:

Apple Silicon GPU Memory Allocation & Ollama Optimization Guide

This guide details how to maximize Unified Memory (vRAM) allocation for local LLM inference on Apple Silicon Macs (M-series) running macOS, specifically tailored for Ollama and high-demand workloads like Qwen models (qwen3.6:27b-mxfp8 and qwen3.6:35b-a3b-mxfp8).


1. Overview & Formula

By default, macOS allocates roughly 75%–80% of total unified memory to the GPU/vRAM, reserving the remainder for the system and desktop applications. When running large models with extended context windows (KV cache), manual overrides grant additional headroom to prevent out-of-memory errors or swapping.

@ThiagoEvoa
ThiagoEvoa / settings-config.md
Last active August 13, 2026 17:21
settings.json Configuration Guide

Overview

The settings.json file controls the global preferences and runtime defaults for the pi CLI. Any changes made to this file take effect on the next launch or when running /reload inside the interactive terminal.


Property Reference

⚙️ Global Settings & Preferences

@ThiagoEvoa
ThiagoEvoa / mcp-configuration.md
Last active August 13, 2026 17:22
mcp.json Configuration Guide

Overview

The mcp.json file registers Model Context Protocol (MCP) servers with the pi agent. MCP servers run as background processes (sidecars) that provide specialized external tools to your LLM (such as Flutter/Dart tooling or GitHub integration).


Property Reference

⚙️ Top-Level Property

@ThiagoEvoa
ThiagoEvoa / local-model-configuration.md
Last active September 26, 2026 15:55
models.json Configuration Guide

Local Model Configuration Guide: Pi Agent & OpenCode

A unified, production-grade guide for configuring local and private LLM providers across both Pi Agent (~/.pi/agent/models.json) and OpenCode (~/.config/opencode/opencode.jsonc), structured across hardware RAM tiers (16 GB to 256 GB).


1. Harness Architectural Overview

Both Pi Agent and OpenCode support running local models (via Ollama, MLX, llama.cpp, vLLM, or LM Studio) with OpenAI-compatible endpoints.

#!/usr/bin/env python3
"""
Ollama & LLM Safe Context Length Calculator
Calculates recommended context length (num_ctx / max_ctx) based on VRAM,
model architecture (GQA, layers, heads), weight size, and KV cache footprint.
Includes dynamic Adaptive Safety Margin calculation based on model scale and live OS memory pressure.
"""
import argparse
import json