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
@@ -31,6 +31,25 @@ describe('serializeContextToXml', () => {
)
})
it('serializes context with user and thread tag with reply_count', () => {
const context: ShumaiMessageContext = {
user: { id: 'usr_1', name: 'Alice', role: 'editor' },
thread: { id: 'th_01JXYZ', replyCount: 3 },
}
expect(serializeContextToXml(context)).toBe(
'<context>\n <user id="usr_1" name="Alice" role="editor" />\n <thread id="th_01JXYZ" reply_count="3" />\n</context>',
)
})
it('serializes context with thread tag without reply_count', () => {
const context: ShumaiMessageContext = {
thread: { id: 'th_01JXYZ' },
}
expect(serializeContextToXml(context)).toBe(
'<context>\n <thread id="th_01JXYZ" />\n</context>',
)
})
it('serializes minimal context with only currentAsset (without ancestors)', () => {
const context: ShumaiMessageContext = {
currentAsset: {