baphuongna/pi-crew/model-routing-context
Claude Code and agent skill by baphuongna/pi-crew
- community
Checking that the SKILL.md file is still in the repository.
Model routing, parent context, thinking level, and prompt construction workflow. Use when changing model fallback, child Pi args, inherited context, task prompts, or compaction/compact-string behavior. When NOT to use: project-level config (use resource-discovery-config); routing for non-pi-crew agents.
Install
npx vskill@latest install baphuongna/pi-crew/model-routing-contextSKILL.md
model-routing-context
Use this skill when working on model/context propagation.
Source patterns distilled
- Pi session context/model state:
source/pi/packages/coding-agent/src/core/session-manager.ts,agent-session.ts, compaction modules - pi-crew model and prompt code:
src/runtime/model-fallback.ts,src/runtime/pi-args.ts,src/runtime/task-runner/prompt-builder.ts,src/runtime/task-output-context.ts,src/extension/team-tool/context.ts
Rules
- Preserve parent model inheritance unless an agent/task/user explicitly provides a non-empty model override.
- Treat empty strings and whitespace model values as absent.
- Carry relevant parent conversation context as reference-only; do not let it override explicit task instructions or safety constraints.
- Distinguish the two compaction layers: host-Pi session compaction (
source/pi/.../session-manager.ts,agent-session.ts, compaction modules) is a reference-only concept — it is not a pi-crew API. - Respect pi-crew's write-side compaction when building context:
compactString/compactValuetranscript truncation insrc/runtime/child-pi/child-pi-transcript.ts:132-164(compactStringexported at :134; cuts marked[truncated]/[pi-crew truncated N entries]). Avoid ballooning prompts with redundant transcript data. - Avoid inline dynamic imports for model providers or prompt helpers.
- When changing model precedence, add tests for undefined, empty, whitespace, agent, task, parent, and explicit tool override cases.
- Redact secrets in context snippets and child prompts where logs/artifacts may persist them.
Enforcement — Model Routing Context Gate
Before changing model precedence or building task prompts, verify:
- [ ] Empty/whitespace model values treated as absent (not as explicit overrides)
- [ ] Model precedence chain understood: tool override → step model → team role → agent model → parent → registry default
- [ ] Thinking level suffix applied correctly (or intentionally omitted)
- [ ] Secrets redacted in context snippets and child prompts
- [ ] Tests cover: undefined, empty, whitespace, agent, task, parent, and explicit tool override cases
If ANY answer is NO → Stop. Verify model routing before proceeding.
Anti-patterns
- Letting
agentModel: ""block parent model fallback. - Treating parent conversation text as executable instructions rather than context.
- Passing full session transcripts to every child by default.
- Losing thinking level or model changes across session switch/fork flows.
Worked Examples
Model precedence chain with all fields
When every level provides a model:
Override at each level
Empty/whitespace/null handling
Common Mistakes
- Empty string blocking parent fallback:
```typescript // ❌ agentModel: "" blocks parent fallback buildConfiguredModelRouting({ agentModel: "" });
// ✅ Empty string treated as absent buildConfiguredModelRouting({ agentModel: undefined }); ```
- Losing thinking level on session switch:
```typescript // ❌ Thinking level not persisted in config const config = { model: "sonnet-4" }; // no thinking
// ✅ Thinking level in model suffix const config = { model: "sonnet-4:medium" }; ```
Verification
Self-restraint
"Creating nothing is a valid result." If the evidence does not support a meaningful change, say so explicitly rather than inventing one. The next attempt may find stronger evidence; an invented change now damages trust in every future report.
"Creating nothing" here means the current model routing is adequate — no changes needed. Inventing routing rules or fallback chains without evidence of failure adds complexity and masks real routing bugs.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/model-routing-context/SKILL.md
Popularity
- Repository stars
- 58
- Repository forks
- 22
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/baphuongna/pi-crew/model-routing-context)