Skip to content

feat: agentic-ai/opencode local model setup with MLX launch script#19

Merged
ulises-c merged 6 commits into
mainfrom
feat/agentic-ai-and-patches
May 28, 2026
Merged

feat: agentic-ai/opencode local model setup with MLX launch script#19
ulises-c merged 6 commits into
mainfrom
feat/agentic-ai-and-patches

Conversation

@ulises-c

@ulises-c ulises-c commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Initial setup of OpenCode as a local AI coding agent, with opencode-local — a launcher that auto-discovers MLX models, starts an OpenAI-compatible server, and opens OpenCode. Designed to run alongside Claude Code using local models on Apple Silicon.

Changes

Main: OpenCode initial setup + local model integration (opencode-local)

  • agentic-ai/OpenCode/ — new directory with config, install script, and launch tooling
  • opencode.json — registers mlx_lm.server (OpenAI-compatible) as a local provider, pre-configured with Qwen 3.5 9B (4bit, MLX)
  • bin/opencode-local — launch script that auto-discovers MLX models in ~/.models/, presents a picker, starts the server, waits for it to be ready, then launches OpenCode. Cleans up on exit. Logs to ~/.local/share/opencode-local/server.log
  • install.sh — symlinks opencode.json to ~/.config/opencode/ and opencode-local to ~/.local/bin/
  • README.md — activation, usage, model recommendations

Minor: Ghostty terminfo fix

  • Added term = xterm-256color to macOS and Linux ghostty configs so remote servers that don't recognize xterm-ghostty still render correctly

Housekeeping

  • Updated TODO.md with ghostty standardization and OpenCode follow-up notes

@ulises-c ulises-c changed the title feat: ghostty term fix + agentic-ai/opencode setup feat: agentic-ai/opencode local model setup with MLX launch script May 24, 2026
@ulises-c

Copy link
Copy Markdown
Owner Author

Memory crash investigation

Reviewed ~/.local/share/opencode-local/server.log from today's sessions. Two distinct issues found:

1. GPU OOM crashes (confirmed)

Two crashes with Qwen3.5-9B-4bit on the 16GB Mac Mini:

libc++abi: terminating due to uncaught exception of type std::runtime_error:
  [METAL] Command buffer execution failed: Insufficient Memory
  (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)

Root cause: The KV cache grows unbounded as conversation context accumulates. Each turn appends to the message history, expanding the prefill KV cache until it exhausts Metal's unified memory allocation. Crashes occurred after 4–6 conversational turns.

Fix applied in 86caf28:

  • --max-tokens 4096 — caps response generation length
  • --prompt-cache-bytes 4294967296 (4GB) — limits total KV cache memory, triggers cache eviction when exceeded

2. GLM-4.7-Flash-5bit model unavailable

The model directory at ~/.models/mlx-community--GLM-4.7-Flash-5bit exists but contains no .safetensors files (likely a partial/corrupted download). The lighter model would be preferable for 16GB machines but needs re-downloading first:

huggingface-cli download mlx-community/GLM-4.7-Flash-5bit \
  --local-dir ~/.models/mlx-community--GLM-4.7-Flash-5bit

Recommendation

Consider documenting these limits in README.md — specifically that Qwen3.5-9B-4bit on 16GB systems may need periodic server restarts for long sessions, and GLM-4.7-Flash-5bit is the safer default for this hardware.

@ulises-c

Copy link
Copy Markdown
Owner Author

Try again with MTP. Do some more fine tuning on KV cache, context length, etc. Merging as is as an initial setup for OpenCode

ulises-c and others added 2 commits May 27, 2026 20:46
…ning

Fixes GPG commit signing in GUI apps (e.g. Obsidian Git plugin) that
don't inherit shell PATH and can't find the gpg binary. Sets
gpg.program to /opt/homebrew/bin/gpg in gitconfig and exports
GPG_TTY=$(tty) in .zshrc for terminal sessions.

Closes #20

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ulises-c
ulises-c marked this pull request as ready for review May 28, 2026 03:48
@ulises-c
ulises-c merged commit d03d6af into main May 28, 2026
3 checks passed
@ulises-c
ulises-c deleted the feat/agentic-ai-and-patches branch May 28, 2026 03:48
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.

GPG signing fails in GUI apps (Obsidian, etc.) due to PATH not being inherited

1 participant