fix: keep local message IDs out of model requests

Direct-model conversation history began carrying GoodBuddy UUIDs after durable context compression was added. OpenAI Responses rejected follow-up messages because provider message IDs must start with msg_, and the same metadata could also reach other protocol payloads.

Model request serialization now strips local IDs across Anthropic Messages, Chat Completions, and Responses while retaining provider IDs during Responses tool rounds. Regression coverage includes compression, tools, and a gated real-model follow-up.

Release note: 修复默认直连模型在继续对话或重新编辑发送时可能因消息 ID 格式错误而失败的问题。
This commit is contained in:
mesalogo
2026-08-16 22:23:03 +08:00
parent 80526c57bf
commit 18263a6b23
3 changed files with 221 additions and 5 deletions
+49
View File
@@ -323,6 +323,55 @@ describe.runIf(enabled)('runtime end-to-end', () => {
120_000
)
it(
'continues real direct-model history with local message IDs',
async () => {
const runtime = new ModelAgentRuntime({
apiKey,
baseUrl,
model: modelName,
protocol,
authentication: 'api-key',
maxOutputTokens: 128
})
try {
const output = await collectText(
runtime.run(
{
requestId: crypto.randomUUID(),
conversationId: crypto.randomUUID(),
workMode: 'ask',
prompt:
'Return exactly this text and nothing else: LOCAL_HISTORY_ID_E2E_OK',
history: [
{
role: 'user',
content:
'The required verification text is LOCAL_HISTORY_ID_E2E_OK.'
},
{
role: 'assistant',
content:
'I will return that verification text when asked.'
}
],
historyMessageIds: [
crypto.randomUUID(),
crypto.randomUUID()
]
},
new AbortController().signal
)
)
expect(output).toContain('LOCAL_HISTORY_ID_E2E_OK')
} finally {
await runtime.dispose()
}
},
120_000
)
it(
'counts a real image in provider-reported input usage',
async () => {