fix: keep cancelled turns as interrupted instead of merging into the next request

- Build runtime history per turn: a cancelled or failed reply keeps its partial
  text plus an interruption marker (or a marker-only placeholder), so its user
  message is never left unanswered and merged into the next request.
- Use the same history for send, manual compaction and Main compact validation.
- OpenCode: keep a cancelled prompt in the reused native session and prefix the
  next turn with a one-time synthetic interruption notice; failed prompts are
  still removed.
- Add an opt-in DeepSeek live test covering direct model and OpenCode.
This commit is contained in:
mesalogo
2026-09-30 02:18:33 +08:00
parent a662b16f5e
commit 608a9a5fec
9 changed files with 371 additions and 25 deletions
+2 -5
View File
@@ -1,6 +1,7 @@
import { registerKnowledgeIpcHandlers } from './knowledge/knowledge-ipc'
import { registerModelSettingsIpcHandlers } from './model-settings-ipc'
import { knowledgeReferenceKey, toKnowledgeReference } from '../shared/knowledge-reference'
import { buildRuntimeHistory } from '../shared/runtime-history'
import { localInferenceService } from './local-inference-service'
import { inferenceActionSchema, inferenceCancelSchema } from '../shared/local-inference-contracts'
import type { NativeClientCoordinator } from './agent/native-client-coordinator'
@@ -4795,11 +4796,7 @@ export function registerIpcHandlers(
) {
throw new Error('对话 Runtime 或 Project 已更改,请刷新后重试')
}
const persistedHistory = conversation.messages
.filter(
(message) =>
message.state === 'complete' && message.content.trim()
)
const persistedHistory = buildRuntimeHistory(conversation.messages)
if (
persistedHistory.length !== request.history.length ||
persistedHistory.some(