mirror of
https://github.com/obra/superpowers.git
synced 2026-04-16 02:02:41 +00:00
fix(opencode): inject bootstrap as user message instead of system message
Move bootstrap injection from experimental.chat.system.transform to experimental.chat.messages.transform, prepending to the first user message instead of adding a system message. This avoids two issues: - System messages repeated every turn inflate token usage (#750) - Multiple system messages break Qwen and other models (#894) Tested on OpenCode 1.3.2 with Claude Sonnet 4.5 — brainstorming skill fires correctly on "Let's make a React to do list" prompt.
This commit is contained in:
@@ -94,12 +94,19 @@ ${toolMapping}
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Use system prompt transform to inject bootstrap (fixes #226 agent reset bug)
|
// Inject bootstrap into the first user message of each session.
|
||||||
'experimental.chat.system.transform': async (_input, output) => {
|
// Using a user message instead of a system message avoids:
|
||||||
|
// 1. Token bloat from system messages repeated every turn (#750)
|
||||||
|
// 2. Multiple system messages breaking Qwen and other models (#894)
|
||||||
|
'experimental.chat.messages.transform': async (_input, output) => {
|
||||||
const bootstrap = getBootstrapContent();
|
const bootstrap = getBootstrapContent();
|
||||||
if (bootstrap) {
|
if (!bootstrap || !output.messages.length) return;
|
||||||
(output.system ||= []).push(bootstrap);
|
const firstUser = output.messages.find(m => m.info.role === 'user');
|
||||||
}
|
if (!firstUser || !firstUser.parts.length) return;
|
||||||
|
// Only inject once
|
||||||
|
if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return;
|
||||||
|
const ref = firstUser.parts[0];
|
||||||
|
firstUser.parts.unshift({ ...ref, type: 'text', text: bootstrap });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user