fix(context-injector): prefix synthetic part ids with prt_

Ensure injected synthetic message parts satisfy OpenCode's part-id schema and avoid new-session Zod validation failures.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
kui123456789
2026-03-30 18:18:07 +08:00
parent 51194e9434
commit 607fce17dc
2 changed files with 3 additions and 1 deletions
@@ -106,6 +106,8 @@ describe("createContextInjectorMessagesTransformHook", () => {
expect(
"synthetic" in secondSyntheticPart && secondSyntheticPart.synthetic === true
).toBe(true)
expect(typeof secondSyntheticPart.id).toBe("string")
expect(secondSyntheticPart.id.startsWith("prt_")).toBe(true)
expect(secondSyntheticPart.id).toBe(firstSyntheticPart.id)
})
+1 -1
View File
@@ -148,7 +148,7 @@ export function createContextInjectorMessagesTransformHook(
// synthetic part pattern (minimal fields)
const syntheticPart = {
id: `synthetic_hook_${sessionID}`,
id: `prt_synthetic_hook_${sessionID}`,
messageID: lastUserMessage.info.id,
sessionID: (lastUserMessage.info as { sessionID?: string }).sessionID ?? "",
type: "text" as const,