TejasLamba2006/cc-subagent-models

6 stars · Last commit 2026-11-17

Patch Claude Code's Agent tool to use any gateway model (9Router, LiteLLM, OpenRouter) per subagent call

README preview

# cc-subagent-models

If you run Claude Code through a gateway like 9Router, LiteLLM, or OpenRouter, you already have access to dozens of models. The problem is that Claude Code's built-in `Agent` tool won't let you use them for subagents, and even if you force a non-Claude model ID through, Claude Code assumes an unrecognized model has a 200k context limit. When your system prompt, skills, and MCP tools already take 150k tokens, a 200k limit leaves almost no room to read files and causes autocompact to thrash and kill the subagent.

`cc-subagent-models` fixes all three parts of the problem in one patch:

1. Unlocks the `Agent` tool's `model` parameter (`free` string mode or `enum` mode).
2. Passes non-Anthropic model IDs straight through the subagent model resolver.
3. Unlocks per-call and per-model context windows (`oc/exo-free[1m]`, `glm/glm-4.5[256k]`, `deepseek/deepseek-reasoner[500k]`), defaults non-Claude gateway models to 1M so autocompact does not thrash, strips the `[<size>]` suffix before sending the API request to your gateway, and writes the usage instructions directly into `~/.claude/CLAUDE.md`.

```bash
npx cc-subagent-models sync --gateway http://localhost:20128/v1/models
npx cc-subagent-models patch --mode free
```

---

## Spawning subagents with model, effort, and context limit

Once patched, `cc-subagent-models` automatically updates `~/.claude/CLAUDE.md` so your lead session knows how to combine model, effort, and context window in natural prompts:

View full repository on GitHub →