feat: manage task process lifetimes and preserve turn history

This commit is contained in:
Ed1s0nZ
2026-09-16 17:52:58 +08:00
parent fd1c13a43d
commit f7882be546
54 changed files with 3650 additions and 330 deletions
+14
View File
@@ -706,6 +706,13 @@ func (m *ExternalMCPManager) CallTool(ctx context.Context, toolName string, args
var client ExternalMCPClient
var blockedByGuard bool
handle, err := m.executionService.Submit(ctx, ExecutionRequest{
ConfirmCancellation: func(confirmCtx context.Context) error {
if confirmer, ok := client.(ExternalCancellationConfirmer); ok {
return confirmer.ConfirmToolCancellation(confirmCtx, actualToolName, args)
}
return fmt.Errorf("external MCP client has no cancellation acknowledgement")
},
Remote: true,
ToolName: toolName,
Arguments: args,
ConversationID: MCPConversationIDFromContext(ctx),
@@ -1649,3 +1656,10 @@ func (m *ExternalMCPManager) StopAll() {
}
m.refreshWg.Wait()
}
// ExternalCancellationConfirmer is an optional adapter contract for MCP
// servers with server-side cancellation receipts or lease/task status APIs.
// Ordinary notifications/cancelled must never be treated as confirmation.
type ExternalCancellationConfirmer interface {
ConfirmToolCancellation(context.Context, string, map[string]interface{}) error
}