Using smaller/less capable local LLMs together with Claude models for a ‘second opinion’

I want to use a Qwen 3.6 local model but have found from testing with various harnesses it is prone to overthinking and goes in circles on some tasks. To avoid this I want to use Qwen as my default/primary model but then spawn a second sub-agent using a more capable Claude model to provide guidance on the solution.

I already have llama.cpp running a server in router mode to run my local models, I asked Claude what approach to use to configure the default model and sub-agent model approach and it recommended to configure a Claude Code agent that passes requests through a LiteLLM proxy to direct requests either to the local model or to cloud based Claude.

Sub-agent approach using LiteLLM

Note this approach requires a Claude subscription with access to API keys. My Pro subscription doesn’t include this, so I couldn’t use this approach, see the following skill only approach that follows this section.

LiteLLM config:

# litellm_config.yaml
model_list:
  - model_name: qwen3.6
    litellm_params:
      model: openai/qwen3.6-35b
      api_base: http://host.docker.internal:8090/v1

  - model_name: claude-opus-5-5
    litellm_params:
      model: anthropic/claude-opus-5-5
      api_key: os.environ/ANTHROPIC_API_KEY

From the LiteLLM docs here, startup a Docker container with the above config:

docker run
-d
--name litellm
--mount type=bind,source="$PWD/litellm_config.yaml",target=/app/config.yaml,readonly
-e LITELLM_MASTER_KEY=[your-local-litellm-key-here]
--add-host=host.docker.internal:host-gateway
-p 4000:4000
docker.litellm.ai/berriai/litellm:latest
--config /app/config.yaml

Point Claude Code at the proxy. Qwen becomes the default model and the opus alias still reaches real Claude:

export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_AUTH_TOKEN=<litellm master key from abovw>
export ANTHROPIC_MODEL=qwen3.6
export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.6 # keep background calls local
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 # the escalation target

Claude’s suggestion on the agent config – add a second-opinion subagent in .claude/agents/second-opinion.md::agents

---
name: second-opinion
description: Use when stuck — same error after 2 fix attempts, torn between approaches, or reasoning is repeating itself. Pass the goal, what was tried, and the exact error text.
model: opus
tools: Read, Grep, Glob
---
You are a senior reviewer consulted by a smaller model that is stuck.
Read the relevant files yourself. Reply briefly with: (1) the diagnosis, (2) the single next step, (3) what to stop doing.

Giving it read-only tools keeps Claude in an advisory role. It can check the code itself instead of relying only on Qwen's summary, and it can't take over the work, which keeps your API spend down.

Claude’s recommendation for the agent trigger and a hook:

Trigger:

Set explicit triggers in CLAUDE.md, for example: "If a fix fails twice, or you are about to re-try something you've already tried, call the second-opinion agent before continuing." Concrete rules like these work much better than "when unsure."

Hook:

Add a hook so the call-out happens even when Qwen misses it. Use a PostToolUse hook on Bash that counts consecutive failures, or repeated edits to the same file, in a state file. At a threshold such as 3, it returns additionalContext telling the model to call second-opinion now. The hook detects the loop; Claude only gets called when it's needed.to

Simpler skill only approach

After trying the agent and LiteLLM approach above, I found out that with a Claude Pro account you can’t create API keys, so the LiteLLM config that references os.environ/ANTHROPIC_API_KEY won’t work. Instead, change the agent config to a Claude skill instead. With the approach you don’t also don’t need LiteLLM, point Claude directly to your llama.cpp URL:

export ANTHROPIC_BASE_URL=http://localhost:8090
export ANTHROPIC_AUTH_TOKEN=dummy # llama-server ignores it unless started with --api-key
export ANTHROPIC_MODEL=qwen/qwen3.6-35b-a3b-agent # router selects the model by this alias
export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen/qwen3.6-35b-a3b-agent # keep background calls local
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=131072 # matches llama-server ctx-size

# ArtifactData has a nested maxLength llama.cpp cannot turn into a grammar
claude --disallowedTools=ArtifactData "$@"

Create this skill in .claude/skills/ that tells the default agent to write to a second-opinion.md file that Claude can pick up:

---
name: second-opinion
description: Ask Claude for a second opinion when stuck. Use when a fix has failed twice, when you are about to retry something already tried, when the same error keeps coming back, or when you are going back and forth between approaches
---
# Second opinion from Claude

Use this as soon as a trigger applies. Do not attempt another fix first.

## Steps

1. Write a brief to `.claude/second-opinion-brief.md` (overwrite it) with these sections:
- **Goal**: what you are trying to achieve, in one or two sentences.
- **Relevant files**: paths Claude should read.
- **Tried so far**: each attempt and what happened.
- **Current error**: the exact error text or failing output, copied verbatim.
- **Question**: what you need decided.

2. From the project root, run this with the Bash tool, setting `timeout` to `600000`:

```
~/.claude/skills/second-opinion/ask-claude.sh
```

3. Follow the **Next step** in the reply and stop doing whatever the reply lists under **Stop doing**. Do not ask again for the same problem unless the sugges>

If the script fails with a login or authentication error, tell the user to run `claude` outside the LiteLLM launcher and `/login` with their Claude Pro accoun>

For the ask-claude.sh script as part of the skill:

#!/usr/bin/env bash
set -euo pipefail

project_dir="$PWD"
brief_file="${1:-$project_dir/.claude/second-opinion-brief.md}"

if [[ ! -s "$brief_file" ]]; then
echo "error: brief file '$brief_file' is missing or empty" >&2
exit 2
fi

system_prompt='You are a senior engineer giving a second opinion to a smaller local model that is stuck.
Read the relevant project files yourself rather than trusting the brief alone.
Reply in under 250 words with exactly three sections:
1. Diagnosis - the most likely root cause.
2. Next step - one concrete action, with file paths and code if needed.
3. Stop doing - what the model should abandon.'

cd "$project_dir"
exec claude -p \
--model "${SECOND_OPINION_MODEL:-opus}" \
--tools "Read,Grep,Glob" \
--no-session-persistence \
--append-system-prompt "$system_prompt" \
< "$brief_file"

In your CLAUDE.md for your project, or globally, define rules for when your primary local model should invoke the second-opinion skill:

# Triggers

If the same error message appears in two test runs, or you are about to re-try something you've already tried, your next action must be the Skill tool with second-opinion. Changing a config key's name or location counts as the same fix. If the suggested step fails, ask again.

So far with Qwen 3.6 I’ve found it’s interpretation of ‘the same error message in two test runs’ is a bit hit and miss. It’s also not particularly reliable on counting occurrences of errors. These rules could be tightened up, and depending on what you’re working on, the wording of the trigger could be made more specific to exactly the types of errors you’re expecting, either error codes or messages. That said, if I find Qwen taking too long trying alternative approaches, you can just prompt it manually to use the second-opinion skill and it works as you’d expect – it summarises the currently tried approaches in the input file and then feeds it into to a prompt with Claude.

botsin.space Mastodon bot migration update to https://mastodon.kevinhooke.com/ – part 2: @zorkbot

Several months back I updated on my progress on moving a number of my personal projects from botsin.space mastodon server to my own https://mastodon.kevinhooke.com instance.

Over the weekend I made some minor updates to reconfigure a series of AWS Lambdas that allow you to play Zork via Mastodon. It’s up again: if you @ the bot at https://mastodon.kevinhooke.com/@zorkbot with the single word ‘play’ you can start a new game. The Lambda runs every 10 minutes., so at worst case You game state should be saved and reloaded on each interaction with the bot, so you can play over a period of time.

Building and serving local LLM models with llama.cpp

For running local LLMs, ollama is an easy way to get up and running, but if you need or want to start tuning model parameters, llama.cpp offers more flexibility (and is generally faster than ollama)

I installed following steps here.

To run on an nvidia GPU I Installed the CUDA toolkit following steps here.

After installing Nvida CUDA toolkit, and attempting to build with it enabled, I got this error:

$ cmake -B build -DGGML_CUDA=ON

CMAKE_BUILD_TYPE=Release
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- GGML_SYSTEM_ARCH: x86
-- Including CPU backend
-- x86 detected
-- Adding CPU backend variant ggml-cpu: -march=native
-- CUDA Toolkit found
-- The CUDA compiler identification is unknown
CMake Error at ggml/src/ggml-cuda/CMakeLists.txt:59 (enable_language):
No CMAKE_CUDA_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment
variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.

Following steps online, it was suggested to add this line to /etc/environment, but this still doesn’t resolve the error:

CUDACXX=/usr/local/cuda~13.3/bin/nvcc

I noticed in this additional steps section, it mentioned to update your path, so added these 2 lines to .bashrc and then this resolved the above config issue:

export PATH=${PATH}:/usr/local/cuda-13.3/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-13.3/lib64

After building with these options llama-cli is able to run. If I point it at the Gemma model I downloaded with ollama though I get errors, and posts online seem mixed on whether you can do this or not, but most seem to imply you need to download a GGUF model specifically for llama.cpp:

./llama-cli --model /usr/share/ollama/.ollama/models/blobs/sha256-4e30e2665218745ef463f722c0bf86be0cab6ee676320f1cfadf91e989107448
Loading model... \0.00.696.653 E llama_model_load: error loading model: done_getting_tensors: wrong number of tensors; expected 2012, got 601
0.00.696.666 E llama_model_load_from_file_impl: failed to load model

After testing with other more recently downloaded models with ollama (e.g. Qwen 3.8 27b), this approach does work, and appears the error is model specific.

I also discovered llama.cpp build detects your GPU model and builds a family specific build. I just replaced a 2060 with a 5070ti and had to rebuild after the change, as the last build binaries were giving errors that the GPU was not detected.

To start a cli chat session using llama and a specific model, I used:

./build/bin/llama-cli --model [path to model file]

I also found out by trial and error that pointing to the sha named model files downloaded by ‘ollama pull’ can be run by llama.ccp

To run a llama server that you can use with harnesses like opencode, pi and oh my pi, I used:

./build/bin/llama-server --model [path to model] --chat-template-kwargs '{"reasoning_effort":"medium"}' --host 0.0.0.0 --port 8090 --alias qwen3.8-27b --ctx-size 49152 --parallel 1 --flash-attn on --cache-type-k q8_0 --cache-type-v q8_0

At this point I also started working with Claude to benchmark the token per second responses with increasing the context size to find a sweetspot where I could run 100% of the model on the GPU with the largest context size without spilling onto the CPU and system ram. Claude seemed particularly good at this, proposing changes, testing, and then retesting tps and checking memory usage.

At this point I started moving to the llama router so I could switch between multiple models from my harness:

./build/bin/llama-server --host 0.0.0.0 --port 8090 --models-preset ./router-models.ini --models-max 1

Here’s an example of my router-models.ini:

; Global defaults applied to every model unless overridden below.
[*]
n-gpu-layers = 999
flash-attn = on
cache-type-k = q8_0
cache-type-v = q8_0
ctx-size = 16384
parallel = 1

[qwen3.8-27b-general]
model = [path to model]
ctx-size = 49152
chat-template-kwargs = {"reasoning_effort":"medium"}

[qwen3.8-27b-agent]
model = [path to model]
ctx-size = 49152
chat-template-kwargs = {"reasoning_effort":"low"}
reasoning-budget = 512
temp = 0.6
repeat-last-n = 256
repeat-penalty = 1.15

[qwen3.6-35b-a3b-agent]
model = [path to model]
ctx-size = 131072
n-cpu-moe = 18
no-mmap = true
reasoning-budget = 512
temp = 0.6
top-p = 0.95
top-k = 20
min-p = 0.0

Running local models on Ubuntu 24.04: ollama with opencode

July 2026: I have a desktop with an Nvidia 2060 with 6GB and was curious whether I’d get any usable performance if I attempted to run an LLM model locally What have I tried so far:

Update Aug 2026: since I started writing this I’ve upgraded to a 5070ti with 16gb vram, so I have a little more realistic vram to play with.

tldr; 6gb vram is enough to run smallest models for general Q&A but not enough to be practical, definitely not agentic coding, but 16gb is doable with a small context.

ollama, opencode with gemma4:e2b

The smallest model I tried first (in terms of number of parameters in the model). Runs reasonably ok for trivial questions. Struggles with any coding tasks on a local repo with opencode – it keeps repeatedly asking the same question, although this might have been before I worked out how to increase the default context size and I may need to take another look.

ollama, opencode, with qwen2.5-coder:14b

Fails to invoke tools (listing the directory for files, gripping file content, running anything outside of the model itself), just outputs json with the tool name and params, but doesn’t seem to actually invoke anything. Read online that it’s tool support was older, and to try the 3.6 models instead

ollama, opencode, with gemma4:12b, 32k context

First actually useful local model. Asked it to review unit tests on a Java project, and create new tests for classes without tests, was was able to call Java and maven to do what was needed.

At this point I felt the model could do enough that I could try one-shotting a request to build a Java web app using JSF 2.3 and run on Tomcat 9 in a Docker container, and older framework on an older version of Tomcat, but a combo I know has some interesting gotchas (JSF 2.3 requires CDI if you use the javax.inject.* annotations, and this is not provided by Tomcat 9), so it would have to know this or work it out in order to reach a working solution). Claude Code Sonnet/Opus 5 can easily one shot this. Here’s my prompt:

Build a Maven based Java 8 webapp using JSF2.3 to run on Tomcat 9. Include a helloworld.xhtml page. Include a Dockerfile to build and run the app on Tomcat 9.

While it recognized it needed to also add a CDI impl like weld, it kept referring to weld versions that were no longer in maven central (I think the groupId and artifactid had changed over time and it was working with knowledge within the model that was out of date.

Also some other minor issues, when adding the weld dependency it overwrote the existing pom.xml rather than adding it to the existing file. When I asked it to out back what it had created before and then add weld it did, but it seemed to require more hand holding and interactive prompting to keep it going in the right direction and point out it’s mistakes. It was not able to produce a working JSF app.

I was curious if I was able to ask factual questions, although without a web search feature. More often than not it responded with out of date answers, but without a web search I guess to be expected. For example, asking about Qwen 3.5 models, it said I was probably asking about 2.5 as 3.5 models have not been released yet.

ollama, opencode, with gemma4:26b-a4b-it-qat, 32k context

Recommended MoE (Mixture of Experts) type model in Reddit subreddits. Definitely capable of coding tasks, able to execute any local tools.

While this model got closer to a working webapp, while creating files and testing starting up the Docker image to rest the results it would random lose track of it’s task and reply:

"I am ready to help you with your software engineering tasks. Please let me know what you would like to do"

Asking it to continue with it’s task does seem to pick up from where it left off, but it’s “a bit flaky”.

It also ran into the “javax.faces.FacesException: Unable to find CDI BeanManager” error and just stopped, saying it would need to investigate. At this point Claude would just do this and work to find a solution, whereas Gemma4:27B seems to need to be told to do this.

ollama, opencode, with Qwen3.6-27B-A3B


Recommended in Reddit subreddits, larger model, moe approach, able to load subset into vram. Discussions that the qwen models are more cable for coding tasks.

I skipped this one for now as suggestions were to try Qwen 3.8 models which were just release this month.

ollama, opencode, with Qwen3.8-27B

Released this month, discussions online and benchmarks are suggesting that the 27b variant of Qwen 3.8 is the first local LLM that’s approaching frontier level capability from 6 months ago, comparable to Claude Sonnet/Opus 4.6 levels.

I think this is right too. this is the first local model I’ve tried so far where it proactively tests if generated code works, checks logs, and if there are errors continues working to resolve the issues. This is more inline with my experience using Claude Code.

ollama, opencode, with hf.co/jrell/Qwen3.8-27B-i1-IQ4_XS-GGUF-Smaller

Here’s where I feel like I’m starting to get into the weeds😀 I’ve started learning about different quantizations for models, where values in the model are stored with lower precision to reduce the model size.

The Qwen3.8-27B is slightly too large to fit in 16GB, but different quant variations of the model get closer. This one is close, but with 32k context it’s still spilling slightly, ollama ps is showing “6% CPU, 94%GPU”. It’s getting me around 20tps which is not great, but it’s somewhat usable.

The issue I’m currently running into however is opencode or the model appear to stop what they’re working on without completing, which is not great. I feel I’ve still some experimenting to do to get a local Claude replacement, but it’s close, definitely close…