opencode-model-router 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/index.ts +16 -29
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ The plugin injects a **delegation protocol** into the system prompt that teaches
|
|
|
14
14
|
|
|
15
15
|
The agent automatically delegates via the Task tool when it recognizes the task complexity, or when plan steps are annotated with `[tier:fast]`, `[tier:medium]`, or `[tier:heavy]` tags.
|
|
16
16
|
|
|
17
|
+
This applies both to plan-driven execution and direct ad-hoc requests. For every new user message, the orchestrator performs an intent gate, splits multi-task requests into atomic units, and routes each unit to `@fast`, `@medium`, or `@heavy`.
|
|
18
|
+
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
19
21
|
### Option A: npm package (recommended)
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -98,43 +98,30 @@ function buildAgentOptions(tier: TierConfig): Record<string, unknown> {
|
|
|
98
98
|
function buildDelegationProtocol(cfg: RouterConfig): string {
|
|
99
99
|
const tiers = getActiveTiers(cfg);
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const tierSummary = Object.entries(tiers)
|
|
102
102
|
.map(([name, t]) => {
|
|
103
103
|
const shortModel = t.model.split("/").pop() ?? t.model;
|
|
104
|
-
const
|
|
105
|
-
return
|
|
104
|
+
const variant = t.variant ? ` (${t.variant})` : "";
|
|
105
|
+
return `@${name}=${shortModel}${variant}`;
|
|
106
106
|
})
|
|
107
|
-
.join("
|
|
108
|
-
|
|
109
|
-
const whenToUse = Object.entries(tiers)
|
|
110
|
-
.map(([name, t]) => `- **@${name}**: ${t.whenToUse.join(", ")}`)
|
|
111
|
-
.join("\n");
|
|
112
|
-
|
|
113
|
-
const rules = cfg.rules.map((r, i) => `${i + 1}. ${r}`).join("\n");
|
|
107
|
+
.join(" | ");
|
|
114
108
|
|
|
115
109
|
return [
|
|
116
110
|
"## Model Delegation Protocol",
|
|
111
|
+
`Preset: ${cfg.activePreset}. Tiers: ${tierSummary}.`,
|
|
117
112
|
"",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"",
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
"",
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
"",
|
|
128
|
-
"### Rules:",
|
|
129
|
-
rules,
|
|
130
|
-
"",
|
|
131
|
-
"### How to delegate:",
|
|
132
|
-
"Use the Task tool with the tier name as `subagent_type`:",
|
|
133
|
-
'- `Task(subagent_type="fast", prompt="Find all files importing AuthContext")`',
|
|
134
|
-
'- `Task(subagent_type="medium", prompt="Implement the UserService class per the spec")`',
|
|
135
|
-
'- `Task(subagent_type="heavy", prompt="Review this auth flow for security vulnerabilities")`',
|
|
113
|
+
"Apply to every user message (plan and ad-hoc):",
|
|
114
|
+
"1. Split multi-part requests into atomic tasks.",
|
|
115
|
+
"2. Respect explicit tier instructions and [tier:fast|medium|heavy] tags.",
|
|
116
|
+
"3. Route read-only search/exploration tasks to @fast.",
|
|
117
|
+
"4. Route implementation/edit/refactor/test/bugfix tasks to @medium.",
|
|
118
|
+
"5. Route architecture/security/performance/complex debugging to @heavy.",
|
|
119
|
+
"6. For mixed requests, delegate each subtask to the matching tier, then synthesize one final response.",
|
|
120
|
+
"7. For trivial single read/grep tasks, execute directly.",
|
|
121
|
+
`8. If uncertain, default to @${cfg.defaultTier}.`,
|
|
136
122
|
"",
|
|
137
|
-
|
|
123
|
+
"Delegate with Task(subagent_type=\"fast|medium|heavy\", prompt=\"...\").",
|
|
124
|
+
"Keep orchestration and final synthesis in the primary agent.",
|
|
138
125
|
].join("\n");
|
|
139
126
|
}
|
|
140
127
|
|