diff --git a/.agents/frameworks/opencode/plugin.ts b/.agents/frameworks/opencode/plugin.ts index 47ffd1a..d8d16d2 100644 --- a/.agents/frameworks/opencode/plugin.ts +++ b/.agents/frameworks/opencode/plugin.ts @@ -48,6 +48,9 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => { 'chat.message': async (input, output) => { logInfoData('chat.message', { input, output }); + const sessionID = output.message.sessionID; + const messageID = output.message.id; + // Session-start injection — runs exactly once per session, prepended so it // reads before the user-prompt-submit nudges on the first turn. if (!initializedSessions.has(input.sessionID)) { @@ -57,8 +60,8 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => { if (startContext) { output.parts.unshift({ id: `prt_${crypto.randomUUID()}`, - sessionID: input.sessionID, - messageID: input.messageID ?? crypto.randomUUID(), + sessionID, + messageID, type: 'text', text: startContext, synthetic: true, @@ -78,8 +81,8 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => { if (context) { output.parts.push({ id: `prt_${crypto.randomUUID()}`, - sessionID: input.sessionID, - messageID: input.messageID ?? crypto.randomUUID(), + sessionID, + messageID, type: 'text', text: context, synthetic: true,