{"data":{"slug":"discovered-a4959b98de43d1b406ffed6b917ae1f9cd41ab94838e8b10","title":"Rjv Codex Ollama Subagents","summary":"Run local Ollama models as separate Codex or opencode processes with repo tools (gemma-explorer, gemma-worker) or as a one-shot text function (ollama-chat.sh). Includes setup, Ollama serve tuning, runner scripts, and time-budget flags.","url":"https:\/\/skillshunter.net\/skills\/discovered-a4959b98de43d1b406ffed6b917ae1f9cd41ab94838e8b10","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-a4959b98de43d1b406ffed6b917ae1f9cd41ab94838e8b10","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-a4959b98de43d1b406ffed6b917ae1f9cd41ab94838e8b10.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-a4959b98de43d1b406ffed6b917ae1f9cd41ab94838e8b10\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before running, ensure Ollama is installed and serving with the tuned flags. Set `OLLAMA_CHAT_MINUTES` and `LOCAL_AGENT_MINUTES` to define time budgets for each runner. Review all generated code, as the model may miss subtle bugs.","instructions":"---\nname: rjv-codex-ollama-subagents\ndescription: \"Mechanism: run local Ollama models as separate Codex or opencode processes with repo tools (gemma-explorer, gemma-worker) or as a one-shot text function (ollama-chat.sh). Covers setup, Ollama serve tuning, runner scripts and time-budget flags. Delegation policy lives in rjv-delegate; host rungs and boxes in rjv-subagents-codex. Triggers: local Ollama, local model, gemma-explorer, gemma-worker, ollama-chat, local-codex-agent, opencode-local, one-shot local model.\"\n---\n\n# Codex + local Ollama\n\nTwo ways to put a local Ollama model to work:\n\n```text\n(a) Separate Ollama-backed Codex processes WITH repo tools\n    main OpenAI Codex = orchestrator \/ reviewer\n    gemma-explorer = local read-only repo scout\n    gemma-worker   = local scoped coding worker\n(b) One-shot local text function, NO repo tools  \u2192 see the last section\n    qwen2.5-coder:14b-instruct = fast checker when Codex supplies exact context\n```\n\n**Which mode:** if the model must read files or edit through the harness, use (a),\na local Codex process. If you can hand it a complete self-contained prompt and it needs\nnothing else from the repo, use (b), the one-shot runner. If you find yourself wishing\na (b) run could \"check the other file\", the job needs repo tools: route it to (a).\n\nMode (a) runs as separate processes because native subagents spawned by an OpenAI\nparent inherit its provider in Codex 0.155.1, so those roles cannot switch to Ollama.\n\n## Setup\n\nWhen the user asks to configure this machine (install the `~\/.codex-ollama` profile),\nor wants to run local Gemma agents now and Ollama is not yet serving with the tuned\nflags, read [`SETUP.md`](SETUP.md). It holds the installer, the `ollama serve`\nflags and the expected model-load evidence.\n\n## Routing and time budgets\n\nDelegation policy lives in `rjv-delegate`; which worker to pick and the\ntime boxes are owned by `rjv-subagents-codex`. Every runner refuses to\nstart without a box: set\n`OLLAMA_CHAT_MINUTES` for `ollama-chat.sh` and `LOCAL_AGENT_MINUTES` for the\nexplorer, worker and `opencode-local.sh`.\n\nLocal Ollama models save main-model tokens and context. Expect no wall-clock gain\nfrom running several at once: Ollama queues concurrent requests.\n\n## Repository-tool examples\n\nRun from the repository root. These are separate Codex processes and can be\nstarted in parallel by the main agent when memory allows.\n\n```sh\nRUNNER=~\/.agents\/skills\/rjv-codex-ollama-subagents\/scripts\/local-codex-agent.sh\n\nLOCAL_AGENT_MINUTES=10 $RUNNER gemma-explorer \\\n  \"Read _docs\/architecture\/frontend.md. Return five bullets. Do not edit files.\"\n\nLOCAL_AGENT_MINUTES=10 $RUNNER gemma-worker \\\n  \"Edit only .plans\/local-demo.md. Add three findings, read it back, and report changed files.\"\n```\n\n`scripts\/opencode-local.sh <provider\/model> \"<brief>\" [dir]` does the same\nthrough a shared opencode server, from any host. It also takes\n`LOCAL_AGENT_MINUTES`. It refuses to start below `OPENCODE_MIN_FREE_PCT` free\nmemory (default 25), and unloads every other model when more than\n`OPENCODE_MAX_LOADED` (default 2) are resident.\n\nThrough the watcher: `rjv-opencode-agents` can also run a local model\n(`OPENCODE_MODELS=\"ollama\/<name>\"`, the model listed under\n`provider.ollama.models` in `~\/.config\/opencode\/opencode.jsonc`). Then:\n\n- **Context.** opencode's own system prompt and tool list take most of a\n  32k window. A 32k model answered \"I'm ready to help!\" to a real brief\n  (2026-11-30). Use a variant built with `PARAMETER num_ctx 65536`\n  (`qwen3-coder-next-64k`), and give that window as the config's `limit.context`.\n- **Brief small.** Ask one narrow question per file, or give a tight spec\n  to type out. An open \"find every bug in 600 lines\" missed the HIGH. The\n  same model answered \"every unavailable path: throws or returns?\" in 30 s and found it.\n- **Text mode, code pasted.** Paste the numbered code into the brief and\n  run `text`. In `repo` mode the same model read the file itself and got\n  the answer wrong. With the code pasted, it listed every path correctly\n  (2026-11-30, 2 min).\n- **Never the gate.** A local hit is a lead. Check it against the code\n  before acting.\n\n## One-shot local text generation (no repo tools)\n\nMode (b): a single local HTTP call, `complete prompt in \u2192 local text out`. No\nCodex, no subagents, no harness. **The local model types; you spec and review.**\nFrom a tight spec a 30B-class model produces ~90% production-quality code at zero\ntoken cost. It misses subtle bugs in its own and others' output, so you review and\ntest every result before it ships.\n\n**Hard limits.** It is a one-shot text function. When a job needs any of the\nfollowing, use mode (a):\n\n- It sees only the pasted prompt: no file reads, shell, web or filesystem.\n- One prompt in, one answer out; no multi-turn self-correction.\n- Its context is only what the prompt holds: the code, signature, conventions.\n- It is weak at judgment and misses subtle and platform bugs. It is never the\n  reviewer.\n\nWhen a local draft is worth it at all, and why high-stakes drafts stay on a\ncloud model: `rjv-delegate` \u00a73 and `rjv-subagents-codex`.\n\n**How to run.** Use the bundled runner (relative to this skill dir). `ollama run`\nemits TTY escape codes into stdout even when redirected, so it is the wrong tool here.\n\n```sh\nOLLAMA_CHAT_MINUTES=5 scripts\/ollama-chat.sh <model> <prompt-file> <out-file> [num_ctx=16384] [keep_alive=30m]\n```\n\nIt calls `localhost:11434\/api\/chat` (non-streaming), writes the raw response to\n`<out-file>`, and prints timing (`wall \/ prompt tok\/s \/ output tok\/s \/ load`). Put\nprompt files in your scratchpad. `keep_alive=30m` keeps the model resident so only\nthe first call within that window pays load; check with `ollama ps`.\n\n**Model choice** (`ollama list` to see what's installed):\n\n| Class | Use for |\n|---|---|\n| Largest available (30B+) | code from spec, test-writing, harder extraction |\n| Small\/fast (7\u20139B) | classification, summaries, quick extraction |\n| Coder variants | small code transforms |\n\n**Writing the prompt.** Quality is won here. The model sees only the prompt file:\n\n1. The spec, decided by you first: algorithms, edge cases, API shapes. Ask it to\n   implement your design.\n2. Real code context inline: the route, function or schema it must fit, plus file\n   conventions (imports, error shapes, validation style). Copy actual snippets.\n3. An exact output contract: \"Output ONLY the code, no markdown fences.\" Models\n   ignore the fences rule ~50% of the time, so strip fences on receipt.\n4. For tests: harness conventions verbatim (imports, seeding, how to invoke).\n\n**Verify the output yourself, every time.**\n\n- Run it: type-check, lint, and tests with known expected values. Reading clean\n  proves nothing; a spike RFC-2047 decoder read cleanly and failed 3\/9 vectors.\n- Review for subtle platform bugs, the class local models miss. Example: SQLite\n  `LIKE` needs an explicit `ESCAPE`, and many ORMs' `like()` don't emit one.\n- Keep final review and open-ended bug-hunting on the main OpenAI model. A local\n  checker may challenge exact supplied code; the main model owns the conclusion.\n","use_cases":["Run local Ollama models as separate Codex processes with repo tools","Use one-shot text function for local model generation without repo tools","Configure and tune Ollama serve with setup scripts","Manage time budgets for model execution using environment variables"],"limitations":[],"compatibility":[],"setup_tip":"When the user asks to configure this machine (install the `~\/.codex-ollama` profile),\nor wants to run local Gemma agents now and Ollama is not yet serving with the tuned\nflags, read [`SETUP.md`](SETUP.md). It holds the installer, the `ollama serve`\nflags and the expected model-load evidence.","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/rjvim\/ai-skills\/blob\/9a942086adef21dbd0c061d9d9e8fd5f43328bf6\/skills\/rjv-codex-ollama-subagents\/SKILL.md","source_commit":"9a942086adef21dbd0c061d9d9e8fd5f43328bf6","license":null,"version":null,"listing_approved_at":"2026-12-03","created_at":"2026-12-02T09:09:37.000000Z","updated_at":"2026-12-03T16:19:55.000000Z","seo_title":"Run Local Ollama Models with Codex and Opencode Processes","seo_description":"Mechanism to run local Ollama models as Codex or opencode processes with repo tools or as a one-shot text function. Includes setup, tuning, and time-budget flags for Oll\u739b","seo_keywords":["local Ollama models","Codex processes","opencode processes","repo tools","one-shot text function","Ollama serve tuning","time-budget flags"]}}