fix: preserve complete remote tool details
Managed SSH Runtime events could complete successfully and then fail local conversation persistence when tool details exceeded a second, smaller renderer-to-Main schema limit. Conversation persistence now stores the complete tool details already accepted from the Runtime, so long remote results no longer leave the final assistant message stuck in a streaming state. Release note: 修复远程项目工具结果较长时会话持久化失败的问题;Runtime 已返回的工具详情现在会完整保存到本地会话。
This commit is contained in:
@@ -3299,6 +3299,15 @@ describe('AssistantDatabase', () => {
|
||||
createdAt: 1_775_000_000_001,
|
||||
state: 'complete' as const,
|
||||
status: '已完成',
|
||||
tools: [
|
||||
{
|
||||
callId: 'remote-tool-call',
|
||||
name: '远程工具',
|
||||
state: 'completed' as const,
|
||||
summary: '完整远程工具结果',
|
||||
output: '远程输出'.repeat(10_000)
|
||||
}
|
||||
],
|
||||
contextCompressions: [
|
||||
{
|
||||
state: 'completed' as const,
|
||||
@@ -3350,6 +3359,15 @@ describe('AssistantDatabase', () => {
|
||||
content: '生成完成',
|
||||
state: 'complete',
|
||||
status: '已完成',
|
||||
tools: [
|
||||
{
|
||||
callId: 'remote-tool-call',
|
||||
name: '远程工具',
|
||||
state: 'completed',
|
||||
summary: '完整远程工具结果',
|
||||
output: '远程输出'.repeat(10_000)
|
||||
}
|
||||
],
|
||||
contextCompressions: [
|
||||
{
|
||||
state: 'completed',
|
||||
|
||||
+10
-1
@@ -3917,7 +3917,16 @@ describe('registerIpcHandlers local conversation persistence', () => {
|
||||
role: 'assistant' as const,
|
||||
content: '增量内容',
|
||||
createdAt: 1,
|
||||
state: 'streaming' as const
|
||||
state: 'streaming' as const,
|
||||
tools: [
|
||||
{
|
||||
callId: 'remote-tool-call',
|
||||
name: '远程工具',
|
||||
state: 'completed' as const,
|
||||
summary: '完整远程工具结果',
|
||||
output: '远程输出'.repeat(10_000)
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
conversationBranchInputSchema,
|
||||
conversationSnapshotSchema,
|
||||
isUntouchedBuiltInDefaultProject,
|
||||
localConversationSaveBatchSchema,
|
||||
persistedProjectExecutionSpaceSchema,
|
||||
projectCreateSchema,
|
||||
projectExecutionSpaceSchema,
|
||||
@@ -203,3 +204,42 @@ describe('conversation branch contracts', () => {
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('conversation persistence contracts', () => {
|
||||
it('preserves complete tool details without persistence length limits', () => {
|
||||
const input = 'input'.repeat(10_000)
|
||||
const output = 'output'.repeat(20_000)
|
||||
const error = 'error'.repeat(10_000)
|
||||
const batch = [
|
||||
{
|
||||
header: {
|
||||
id: '00000000-0000-4000-8000-000000000301',
|
||||
title: '远程工具会话',
|
||||
updatedAt: 1
|
||||
},
|
||||
messages: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000302',
|
||||
role: 'assistant',
|
||||
content: '',
|
||||
createdAt: 1,
|
||||
state: 'complete',
|
||||
tools: [
|
||||
{
|
||||
callId: 'remote-tool-call',
|
||||
name: '远程工具',
|
||||
state: 'completed',
|
||||
summary: '完整远程工具结果',
|
||||
input,
|
||||
output,
|
||||
error
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
expect(localConversationSaveBatchSchema.parse(batch)).toEqual(batch)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -133,8 +133,8 @@ export type ConversationQueueItem = z.infer<
|
||||
|
||||
export const conversationToolActivitySchema = z
|
||||
.object({
|
||||
callId: z.string().max(256).optional(),
|
||||
name: z.string().max(200),
|
||||
callId: z.string().optional(),
|
||||
name: z.string(),
|
||||
state: z.enum([
|
||||
'pending',
|
||||
'running',
|
||||
@@ -144,10 +144,10 @@ export const conversationToolActivitySchema = z
|
||||
'cancelled',
|
||||
'interrupted'
|
||||
]),
|
||||
summary: z.string().max(2_000),
|
||||
input: z.string().max(4_000).optional(),
|
||||
output: z.string().max(16_000).optional(),
|
||||
error: z.string().max(2_000).optional()
|
||||
summary: z.string(),
|
||||
input: z.string().optional(),
|
||||
output: z.string().optional(),
|
||||
error: z.string().optional()
|
||||
})
|
||||
.strict()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user