feat(agent): move thread metadata to structured context XML (#373)

* feat(agent): move thread metadata to structured context XML

* feat(core): dynamically inject thread metadata in getSessionEntries
This commit is contained in:
Yiling-J
2026-09-01 17:42:56 +08:00
committed by GitHub
parent c2f477a391
commit 64b68e7d63
11 changed files with 410 additions and 64 deletions
+15
View File
@@ -163,6 +163,21 @@ User messages may contain a <context> block detailing the user, active asset loc
systemPrompt += `\n\nYour current model supports the following input types: ${modelConfig.input.join(', ')}.`
}
const isCommentMode =
!!params.userCommentId ||
(params.sessionId
? (
await prisma.agentSession.findUnique({
where: { id: params.sessionId },
select: { type: true },
})
)?.type === 'comment'
: false)
if (isCommentMode) {
systemPrompt += `\n\n# Comment Threads\nWhen operating in comment mode, previous top-level messages in the conversation history may contain a <thread id="..." reply_count="..." /> tag indicating an earlier discussion thread with replies. If a user's question refers to or depends on earlier comments or discussions, you can use the 'read_thread' tool with the thread ID to inspect all replies in that thread.`
}
const agentConfig = agent.config as PrismaJson.AgentConfig | null | undefined
const thinkingLevel = agentConfig?.thinkingLevel || 'off'