原始内容
name: token-router description: Route oversized logs, source files, and long routeable agent-context reference files through a local Ollama model before analysis. Use when the user needs to analyze massive error logs, stack traces, source files over roughly 300 lines, or long AGENTS.md/CLAUDE.md-style reference docs while preserving token budget. Trigger on requests such as "optimize tokens for this log", "look at this big file using the local router", or "route AGENTS.md context".
Token Router (Pi fork)
Use this skill to reduce cloud context load for large logs, source files, or long routeable agent-context reference files. A local Ollama model selects likely line ranges, and scripts/router.py returns raw, unedited slices from the original file.
Workflow
- For large logs, stack traces, source files, or long routeable agent-context docs, run the router before loading the whole file:
python3 scripts/router.py <mode> <PATH_TO_TARGET_FILE>
Pass the user question when it contains useful domain terms:
python3 scripts/router.py heavy_code path/to/file.py --query "token expiration"
For long agent instruction references, use agent_context with the user's task terms:
python3 scripts/router.py agent_context path/to/agent-context/frontend.md --query "frontend testing workflow"
- Choose
error_logfor logs or stack traces,heavy_codefor long source files, andagent_contextfor long routeable instruction references. - Analyze only the returned raw slices. The local model is a line-number router, not a summarizer.
- If the returned slice is too narrow, rerun the router or inspect a larger nearby range directly.
- Do not assume unseen surrounding code. Ask for or retrieve more context before making claims that depend on omitted lines.
Configuration
The router defaults to the locally installed gemma4:e2b-it-q4_K_M model at http://localhost:11434/api/generate. Use OLLAMA_MODEL and OLLAMA_URL to override. See the original README and docs/token-router/benchmark-report.md for details.
Regression Tests
python3 scripts/run_router_tests.py tests/router-tests.json