opencode-model-router 1.1.7 → 1.1.9
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/package.json +1 -1
- package/src/index.ts +21 -16
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -580,7 +580,22 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
580
580
|
let cfg = loadConfig();
|
|
581
581
|
const activeTiers = getActiveTiers(cfg);
|
|
582
582
|
|
|
583
|
+
// Track subagent sessions so we can skip delegation protocol injection.
|
|
584
|
+
// Populated by chat.params (which has the agent name) before system.transform fires.
|
|
585
|
+
const subagentSessionIDs = new Set<string>();
|
|
586
|
+
|
|
583
587
|
return {
|
|
588
|
+
// -----------------------------------------------------------------------
|
|
589
|
+
// Detect subagent calls via chat.params (has agent field).
|
|
590
|
+
// When the agent name matches a registered tier, record the sessionID.
|
|
591
|
+
// -----------------------------------------------------------------------
|
|
592
|
+
"chat.params": async (input: any, _output: any) => {
|
|
593
|
+
const tierNames = Object.keys(activeTiers);
|
|
594
|
+
if (input.agent && tierNames.includes(input.agent)) {
|
|
595
|
+
subagentSessionIDs.add(input.sessionID);
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
|
|
584
599
|
// -----------------------------------------------------------------------
|
|
585
600
|
// Register tier agents + commands at load time
|
|
586
601
|
// -----------------------------------------------------------------------
|
|
@@ -659,8 +674,8 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
659
674
|
// -----------------------------------------------------------------------
|
|
660
675
|
// Inject delegation protocol — uses cached config (invalidated on /preset or /budget)
|
|
661
676
|
// Only inject for the primary orchestrator, NOT for subagent calls.
|
|
662
|
-
//
|
|
663
|
-
//
|
|
677
|
+
// Subagents get confused by delegation instructions when they should
|
|
678
|
+
// just execute a task (especially smaller models like Haiku).
|
|
664
679
|
// -----------------------------------------------------------------------
|
|
665
680
|
"experimental.chat.system.transform": async (_input: any, output: any) => {
|
|
666
681
|
try {
|
|
@@ -669,20 +684,10 @@ const ModelRouterPlugin: Plugin = async (_ctx: PluginInput) => {
|
|
|
669
684
|
// Use last known config if file read fails
|
|
670
685
|
}
|
|
671
686
|
|
|
672
|
-
// Skip injection
|
|
673
|
-
//
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
if (model) {
|
|
677
|
-
const tiers = getActiveTiers(cfg);
|
|
678
|
-
const isSubagentModel = Object.values(tiers).some((tier) => {
|
|
679
|
-
const parts = tier.model.split("/");
|
|
680
|
-
const providerID = parts[0];
|
|
681
|
-
const modelID = parts.slice(1).join("/");
|
|
682
|
-
return model.providerID === providerID && model.id === modelID;
|
|
683
|
-
});
|
|
684
|
-
if (isSubagentModel) return;
|
|
685
|
-
}
|
|
687
|
+
// Skip injection for child (subagent) sessions.
|
|
688
|
+
// Child sessions are detected via session.created events with a parentID.
|
|
689
|
+
const sessionID = _input?.sessionID;
|
|
690
|
+
if (sessionID && subagentSessionIDs.has(sessionID)) return;
|
|
686
691
|
|
|
687
692
|
output.system.push(buildDelegationProtocol(cfg));
|
|
688
693
|
},
|