[BUG] Without an explicit behavesAs mapping, unrecognized models (e.g. local models via Ollama) misinterpret Claude Code's tool/skill/agent scaffolding as user input
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code is pointed at a model not in its built-in catalog (via --model with no corresponding modelPicker entry), it correctly shows a warning:
"<model>" isn't described by this version's model catalog...
[claude-code:unrecognized_model]
However, this is more than an informational/context-window-assumption issue as the warning text suggests. Without adding an explicit behavesAs mapping (e.g. "behavesAs": "claude-sonnet-4-6") in ~/.claude/settings.json, the model itself visibly misinterprets the injected harness content — skill listings, agent listings, and system-reminder blocks — as literal user-authored input, producing hallucinated/confused responses that reference Claude Code internals as if the user had typed them.
What Should Happen?
The unrecognized_model warning states its consequence is limited to context-window/auto-compact assumptions ("auto-compact keeps this session within 200k tokens"). It should not also cause a functional failure in how the model interprets its own scaffolding.
Error Messages/Logs
without the behaves as:
▗ ▗ ▖ ▖ Claude Code v2.1.263
GLM 4.7 Flash with low effort · API Usage Billing
▘▘ ▝▝ ~/claude-minimal-test
❯ Say exactly: Hello World
Thought for 1m 32s
I'll help you create a simple test file for this minimal test project. Let me write a basic file with a simple message.
⏺ Write(test.txt)
User rejected write to test.txt
Hello, World!
This is a minimal test file to verify the Claude Code environment
is working correctly.
✻ Cooked for 1m 36s · done 12:31 AM
/exit and relaunch
▗ ▖ ▖ Claude Code v2.1.263
GLM 4.7 Flash with low effort · API Usage Billing
▘▘ ▝▝ ~/claude-minimal-test
❯ Say exactly: Hello World
Thought for 20s
I'd be happy to help create a structured task list! However, I need to know what task you'd like me to help with first.
Could you tell me what you'd like to accomplish? For example:
- A specific feature to implement
- A bug to fix
- A refactoring task
- A research project
- Something else?
Once you provide the task, I'll create a structured task list to help organize the work.
✻ Sautéed for 25s · done 12:34 AM
⏺ Unknown command: /eixt. Did you mean /exit?
❯ yes
Thought for 1m 8s
Hi! 👋
I'm ready to help you with your software engineering tasks. What would you like to work on?
For example, I can:
- Write or review code
- Help debug issues
- Set up or configure tools
- Create workflows
- Run tests
- Deploy applications
- Or anything else related to development
What's on your mind today?
✻ Baked for 1m 14s · done 12:38 AM
────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────
⏸ manual mode on · ? for shortcuts · ← for agents
This problem is fixed with the correct config file with behavesAs and model picker.
Steps to Reproduce
Configure ANTHROPIC_BASE_URL to point at a local Ollama instance serving any model not in Claude Code's catalog.
Run claude --model <unrecognized-model-name> with no modelPicker/behavesAs entry for it.
Send a trivial prompt (e.g. "Say exactly: Hello World").
Observe the model's response engaging with or hallucinating about the injected skill/agent/system-reminder content, rather than treating those as background context and simply answering the prompt.
Add a modelPicker entry with "behavesAs": "claude-sonnet-4-6" (or similar) for the same model, and observe the issue disappears — the model responds normally.
Claude Model
Other
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.260 (also reproduced on 2.1.261, 2.1.263)
Platform
Other
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Environment: Local Ollama-served model (glm-4.7-flash), routed via ANTHROPIC_BASE_URL=http://localhost:11434
Either (a) update the warning text to clearly state that unrecognized models may also need a behavesAs mapping for correct scaffolding interpretation, not just context-window sizing, or (b) apply some default behavesAs-equivalent normalization automatically for unrecognized models so this doesn't require manual configuration to get correct baseline behavior. (recommended). I attached my working model here.
This is my corrected ~/.claude/settings.json
settings.json