Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Harden MCP tool execution and synchronization https://github.com/siyuan-note/siyuan/issues/13795

Danielf5e9c0c56c34
diff --git a/kernel/agent/tools.go b/kernel/agent/tools.go
index 9600131e28..3f7ada3f89 100644
--- a/kernel/agent/tools.go
+++ b/kernel/agent/tools.go
@@ -98,7 +98,8 @@ func executeTool(ctx context.Context, tc openai.ToolCall, sessionID string) (res
return "tool execution error: " + err.Error(), true, false
}
if err = validator.ValidateOutputContext(ctx, result); err != nil {
- return "invalid tool output: " + err.Error(), true, false
+ return "invalid tool output after execution; execution result may have side effects and must not be retried automatically: " +
+ err.Error(), true, true
}
return resultToString(result), result.IsError, result.ExecutionUnknown
@@ -236,17 +237,21 @@ func resultToString(result tools.CallToolResult) string {
for _, item := range result.Content {
if item.Type == "text" {
parts = append(parts, item.Text)
+ continue
+ }
+ if data, err := json.Marshal(item); err == nil {
+ parts = append(parts, string(data))
}
}
- if len(parts) == 0 && result.HasStructuredContent() {
+ if joined := strings.Join(parts, "\n"); joined != "" {
+ return joined
+ }
+ if result.HasStructuredContent() {
if data, err := json.Marshal(result.StructuredContent); err == nil {
return string(data)
}
}
- if len(parts) == 0 {
- return "(empty result)"
- }
- return strings.Join(parts, "\n")
+ return "(empty result)"
}
func parseToolArgs(argsJSON string) map[string]any {
diff --git a/kernel/agent/tools_test.go b/kernel/agent/tools_test.go
index 2bbb77d0c2..d8c711cf00 100644
--- a/kernel/agent/tools_test.go
+++ b/kernel/agent/tools_test.go
@@ -120,6 +120,27 @@ func TestResultToStringUsesExplicitNullStructuredContent(t *testing.T) {
}
}
+func TestResultToStringUsesStructuredContentForEmptyText(t *testing.T) {
+ result := resultToString(tools.CallToolResult{
+ Content: []tools.ContentItem{{Type: "text"}},
+ StructuredContent: map[string]any{"status": "ok"},
+ })
+ if result != `{"status":"ok"}` {
+ t.Fatalf("unexpected structured result: %q", result)
+ }
+}
+
+func TestResultToStringTranslatesNonTextContent(t *testing.T) {
+ var image tools.ContentItem
+ if err := json.Unmarshal([]byte(`{"type":"image","data":"aW1hZ2U=","mimeType":"image/png"}`), &image); err != nil {
+ t.Fatal(err)
+ }
+ result := resultToString(tools.CallToolResult{Content: []tools.ContentItem{image}})
+ if !strings.Contains(result, `"type":"image"`) || !strings.Contains(result, `"mimeType":"image/png"`) {
+ t.Fatalf("unexpected image result: %q", result)
+ }
+}
+
func TestNeedsConfirmScopesReadOnlyActionsByToolSource(t *testing.T) {
const externalWrite = "test_external_write"
const externalRead = "test_external_read"
@@ -357,7 +378,7 @@ func TestExecuteToolRejectsInvalidStructuredOutput(t *testing.T) {
result, isErr, executionUnknown := executeTool(context.Background(), openai.ToolCall{
Function: openai.FunctionCall{Name: toolName, Arguments: `{}`},
}, "")
- if !isErr || executionUnknown || !strings.Contains(result, "invalid tool output") {
+ if !isErr || !executionUnknown || !strings.Contains(result, "must not be retried automatically") {
t.Fatalf("unexpected tool result: result=%q, isErr=%v, executionUnknown=%v", result, isErr, executionUnknown)
}
}
diff --git a/kernel/mcp/client/mcp.go b/kernel/mcp/client/mcp.go
index ffb28a831e..38473b6c35 100644
--- a/kernel/mcp/client/mcp.go
+++ b/kernel/mcp/client/mcp.go
@@ -40,6 +40,7 @@ import (
const (
defaultMCPServerTimeout = 30 * time.Second
+ maxMCPToolListPages = 1000
)
type Connection struct {
@@ -233,7 +234,7 @@ func connectOneServer(ctx context.Context, server conf.MCPServer, interactive bo
}
listCtx, listCancel := context.WithTimeout(ctx, serverTimeout(server))
- toolList, err := session.ListTools(listCtx, nil)
+ toolList, err := listAllMCPTools(listCtx, session.ListTools)
listCancel()
if err != nil {
if ctx.Err() != nil {
@@ -268,13 +269,13 @@ func connectOneServer(ctx context.Context, server conf.MCPServer, interactive bo
oauthHandler.disableInteractive()
}
- baseNameCounts := make(map[string]int, len(toolList.Tools))
- for _, tool := range toolList.Tools {
+ baseNameCounts := make(map[string]int, len(toolList))
+ for _, tool := range toolList {
baseNameCounts["mcp_"+sanitize(server.Name)+"_"+sanitize(tool.Name)]++
}
serverNameCollision := sanitizedServerNameCollision(server)
registeredTools := map[string]*tools.Tool{}
- for _, t := range toolList.Tools {
+ for _, t := range toolList {
tool := t
baseName := "mcp_" + sanitize(server.Name) + "_" + sanitize(tool.Name)
name := mcpToolName(server, tool.Name,
@@ -331,6 +332,34 @@ func connectOneServer(ctx context.Context, server conf.MCPServer, interactive bo
return connection
}
+func listAllMCPTools(ctx context.Context,
+ listPage func(context.Context, *mcp.ListToolsParams) (*mcp.ListToolsResult, error)) ([]*mcp.Tool, error) {
+ var (
+ allTools []*mcp.Tool
+ params *mcp.ListToolsParams
+ )
+ seenCursors := map[string]struct{}{}
+ for page := 0; page < maxMCPToolListPages; page++ {
+ result, err := listPage(ctx, params)
+ if err != nil {
+ return nil, err
+ }
+ if result == nil {
+ return nil, fmt.Errorf("tools/list returned an empty response")
+ }
+ allTools = append(allTools, result.Tools...)
+ if result.NextCursor == "" {
+ return allTools, nil
+ }
+ if _, exists := seenCursors[result.NextCursor]; exists {
+ return nil, fmt.Errorf("tools/list repeated cursor %q", result.NextCursor)
+ }
+ seenCursors[result.NextCursor] = struct{}{}
+ params = &mcp.ListToolsParams{Cursor: result.NextCursor}
+ }
+ return nil, fmt.Errorf("tools/list exceeded %d pages", maxMCPToolListPages)
+}
+
func sanitizedServerNameCollision(server conf.MCPServer) bool {
mcpMu.Lock()
defer mcpMu.Unlock()
@@ -384,7 +413,12 @@ func closeConnections(connections []Connection) {
}
func connectServer(ctx context.Context, server conf.MCPServer, interactive bool) (*mcp.ClientSession, *exec.Cmd, *mcpOAuthHandler, error) {
- c := mcp.NewClient(&mcp.Implementation{Name: "siyuan", Version: "3.0"}, nil)
+ c := mcp.NewClient(&mcp.Implementation{Name: "siyuan", Version: "3.0"}, &mcp.ClientOptions{
+ ToolListChangedHandler: func(context.Context, *mcp.ToolListChangedRequest) {
+ logging.LogInfof("mcp: server [%s] tool list changed, reconnecting", server.Name)
+ go reconnectMCPServer(server.ID)
+ },
+ })
switch server.Type {
case "stdio":
@@ -555,14 +589,20 @@ func callMCPToolOnce(call func() (*mcp.CallToolResult, error), reconnect func(er
}
}
- var textParts []string
+ contentItems := make([]tools.ContentItem, 0, len(result.Content))
for _, content := range result.Content {
- if textContent, ok := content.(*mcp.TextContent); ok {
- textParts = append(textParts, textContent.Text)
+ data, marshalErr := content.MarshalJSON()
+ if marshalErr != nil {
+ return invalidMCPContentResult()
+ }
+ var item tools.ContentItem
+ if unmarshalErr := json.Unmarshal(data, &item); unmarshalErr != nil {
+ return invalidMCPContentResult()
}
+ contentItems = append(contentItems, item)
}
- text := strings.Join(textParts, "\n")
- if text == "" {
+ if len(contentItems) == 0 {
+ text := ""
if result.StructuredContent != nil {
if data, err := json.Marshal(result.StructuredContent); err == nil {
text = string(data)
@@ -571,6 +611,7 @@ func callMCPToolOnce(call func() (*mcp.CallToolResult, error), reconnect func(er
if text == "" {
text = "(empty result)"
}
+ contentItems = append(contentItems, tools.ContentItem{Type: "text", Text: text})
}
structuredContentSet := result.StructuredContent != nil
if !structuredContentSet && structuredContentExpected && !result.IsError {
@@ -584,13 +625,25 @@ func callMCPToolOnce(call func() (*mcp.CallToolResult, error), reconnect func(er
syr := tools.CallToolResult{
IsError: result.IsError,
- Content: []tools.ContentItem{{Type: "text", Text: text}},
+ Content: contentItems,
StructuredContent: result.StructuredContent,
StructuredContentSet: structuredContentSet,
}
return syr
}
+func invalidMCPContentResult() tools.CallToolResult {
+ return tools.CallToolResult{
+ Content: []tools.ContentItem{{
+ Type: "text",
+ Text: "mcp tool returned invalid content after execution; execution result may have side effects and must not be " +
+ "retried automatically",
+ }},
+ IsError: true,
+ ExecutionUnknown: true,
+ }
+}
+
func trustedReadOnlyHint(server conf.MCPServer, tool *mcp.Tool) bool {
return server.TrustToolAnnotations && tool.Annotations != nil && tool.Annotations.ReadOnlyHint
}
@@ -644,6 +697,24 @@ func reconnectMCP(serverName string) bool {
return true
}
+func reconnectMCPServer(serverID string) bool {
+ mcpMu.Lock()
+ servers := append([]conf.MCPServer(nil), mcpServers...)
+ found := false
+ for _, server := range servers {
+ if server.ID == serverID && server.Enabled {
+ found = true
+ break
+ }
+ }
+ mcpMu.Unlock()
+ if !found {
+ return false
+ }
+ ReconnectMCPAsync(servers, []string{serverID}, nil)
+ return true
+}
+
// ReconnectMCPAsync 用最新的 server 配置异步重连,不阻塞调用方(如 setAI 配置保存)。
// 适用于配置变更(开关切换、编辑、增删 server)后让连接立即跟上,而非等下次 Agent 请求。
func ReconnectMCPAsync(servers []conf.MCPServer, forceServerIDs, interactiveServerIDs []string) {
diff --git a/kernel/mcp/client/mcp_test.go b/kernel/mcp/client/mcp_test.go
index 6d1a7bdf09..b7a1eb02f5 100644
--- a/kernel/mcp/client/mcp_test.go
+++ b/kernel/mcp/client/mcp_test.go
@@ -18,6 +18,7 @@ package client
import (
"context"
+ "encoding/json"
"errors"
"testing"
"time"
@@ -94,6 +95,80 @@ func TestCallMCPToolOnceDoesNotInventMissingStructuredContent(t *testing.T) {
}
}
+func TestCallMCPToolOncePreservesNonTextContent(t *testing.T) {
+ result := callMCPToolOnce(func() (*mcp.CallToolResult, error) {
+ return &mcp.CallToolResult{
+ Content: []mcp.Content{&mcp.ImageContent{
+ Data: []byte("image-data"),
+ MIMEType: "image/png",
+ }},
+ }, nil
+ }, func(error) {}, false)
+ if len(result.Content) != 1 || result.Content[0].Type != "image" {
+ t.Fatalf("image content was not preserved: %#v", result.Content)
+ }
+ data, err := json.Marshal(result.Content[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ var decoded struct {
+ Type string `json:"type"`
+ Data []byte `json:"data"`
+ MIMEType string `json:"mimeType"`
+ }
+ if err = json.Unmarshal(data, &decoded); err != nil {
+ t.Fatal(err)
+ }
+ if decoded.Type != "image" || string(decoded.Data) != "image-data" || decoded.MIMEType != "image/png" {
+ t.Fatalf("unexpected image content: %#v", decoded)
+ }
+}
+
+func TestListAllMCPToolsFollowsPagination(t *testing.T) {
+ var cursors []string
+ result, err := listAllMCPTools(t.Context(),
+ func(_ context.Context, params *mcp.ListToolsParams) (*mcp.ListToolsResult, error) {
+ cursor := ""
+ if params != nil {
+ cursor = params.Cursor
+ }
+ cursors = append(cursors, cursor)
+ switch cursor {
+ case "":
+ return &mcp.ListToolsResult{
+ Tools: []*mcp.Tool{{Name: "first"}},
+ NextCursor: "page-2",
+ }, nil
+ case "page-2":
+ return &mcp.ListToolsResult{
+ Tools: []*mcp.Tool{{Name: "second"}},
+ }, nil
+ default:
+ t.Fatalf("unexpected cursor: %q", cursor)
+ return nil, nil
+ }
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(result) != 2 || result[0].Name != "first" || result[1].Name != "second" {
+ t.Fatalf("unexpected tools: %#v", result)
+ }
+ if len(cursors) != 2 || cursors[0] != "" || cursors[1] != "page-2" {
+ t.Fatalf("unexpected cursors: %#v", cursors)
+ }
+}
+
+func TestListAllMCPToolsRejectsRepeatedCursor(t *testing.T) {
+ _, err := listAllMCPTools(t.Context(),
+ func(context.Context, *mcp.ListToolsParams) (*mcp.ListToolsResult, error) {
+ return &mcp.ListToolsResult{NextCursor: "same"}, nil
+ })
+ if err == nil {
+ t.Fatal("expected repeated cursor to fail")
+ }
+}
+
func TestTrustedReadOnlyHint(t *testing.T) {
tool := &mcp.Tool{Annotations: &mcp.ToolAnnotations{ReadOnlyHint: true}}
if trustedReadOnlyHint(conf.MCPServer{}, tool) {
diff --git a/kernel/mcp/server.go b/kernel/mcp/server.go
index 3cfcb5784a..d435ddcc52 100644
--- a/kernel/mcp/server.go
+++ b/kernel/mcp/server.go
@@ -186,12 +186,20 @@ func syncTool(server *mcpsdk.Server, name string, tool *tools.Tool) {
return toolErrorResult(err.Error()), nil
}
if err = validator.ValidateOutputContext(ctx, result); err != nil {
- return toolErrorResult(fmt.Sprintf("invalid tool output: %v", err)), nil
+ return toolErrorResult(fmt.Sprintf(
+ "invalid tool output after execution; execution result may have side effects and must not be retried automatically: %v",
+ err)), nil
}
content := make([]mcpsdk.Content, 0, len(result.Content))
for _, item := range result.Content {
- content = append(content, &mcpsdk.TextContent{Text: item.Text})
+ converted, convertErr := convertContentItem(item)
+ if convertErr != nil {
+ return toolErrorResult(fmt.Sprintf(
+ "invalid tool content after execution; execution result may have side effects and must not be retried automatically: %v",
+ convertErr)), nil
+ }
+ content = append(content, converted)
}
structuredContent := result.StructuredContent
if result.HasStructuredContent() && structuredContent == nil {
@@ -205,6 +213,23 @@ func syncTool(server *mcpsdk.Server, name string, tool *tools.Tool) {
})
}
+func convertContentItem(item tools.ContentItem) (mcpsdk.Content, error) {
+ data, err := json.Marshal(item)
+ if err != nil {
+ return nil, err
+ }
+ wrapped := append([]byte(`{"content":[`), data...)
+ wrapped = append(wrapped, []byte(`]}`)...)
+ var result mcpsdk.CallToolResult
+ if err = json.Unmarshal(wrapped, &result); err != nil {
+ return nil, err
+ }
+ if len(result.Content) != 1 {
+ return nil, fmt.Errorf("expected one content item, got %d", len(result.Content))
+ }
+ return result.Content[0], nil
+}
+
func toolErrorResult(message string) *mcpsdk.CallToolResult {
return &mcpsdk.CallToolResult{
Content: []mcpsdk.Content{&mcpsdk.TextContent{Text: message}},
diff --git a/kernel/mcp/server_test.go b/kernel/mcp/server_test.go
index 612f3fc038..587037b7dc 100644
--- a/kernel/mcp/server_test.go
+++ b/kernel/mcp/server_test.go
@@ -236,6 +236,49 @@ func TestToolInputAndOutputValidation(t *testing.T) {
if !outputResult.IsError || outputResult.StructuredContent != nil {
t.Fatalf("invalid output was returned: %#v", outputResult)
}
+ outputText, ok := outputResult.Content[0].(*mcpsdk.TextContent)
+ if !ok || !strings.Contains(outputText.Text, "must not be retried automatically") {
+ t.Fatalf("invalid output did not warn against retrying: %#v", outputResult.Content)
+ }
+}
+
+func TestNonTextToolContentIsPreserved(t *testing.T) {
+ server, httpServer := newTestHTTPServer(t)
+ var imageContent tools.ContentItem
+ if err := json.Unmarshal(
+ []byte(`{"type":"image","data":"aW1hZ2UtZGF0YQ==","mimeType":"image/png"}`), &imageContent); err != nil {
+ t.Fatal(err)
+ }
+ syncTool(server, "image_output", &tools.Tool{
+ Name: "image_output",
+ InputSchema: tools.ToolSchema{Type: "object"},
+ Handler: func(map[string]any) (tools.CallToolResult, error) {
+ return tools.CallToolResult{
+ Content: []tools.ContentItem{imageContent},
+ }, nil
+ },
+ })
+
+ client := mcpsdk.NewClient(&mcpsdk.Implementation{Name: "test-client", Version: "1.0.0"}, nil)
+ session, err := client.Connect(t.Context(), &mcpsdk.StreamableClientTransport{Endpoint: httpServer.URL}, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() {
+ session.Close()
+ })
+
+ result, err := session.CallTool(t.Context(), &mcpsdk.CallToolParams{Name: "image_output"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(result.Content) != 1 {
+ t.Fatalf("unexpected content: %#v", result.Content)
+ }
+ image, ok := result.Content[0].(*mcpsdk.ImageContent)
+ if !ok || string(image.Data) != "image-data" || image.MIMEType != "image/png" {
+ t.Fatalf("unexpected image content: %#v", result.Content[0])
+ }
}
func TestExplicitNullStructuredContent(t *testing.T) {
diff --git a/kernel/mcp/tools/types.go b/kernel/mcp/tools/types.go
index ed6eff3eb5..72be4e0374 100644
--- a/kernel/mcp/tools/types.go
+++ b/kernel/mcp/tools/types.go
@@ -161,4 +161,24 @@ func (r *CallToolResult) UnmarshalJSON(data []byte) error {
type ContentItem struct {
Type string `json:"type"`
Text string `json:"text"`
+ raw json.RawMessage
+}
+
+func (item ContentItem) MarshalJSON() ([]byte, error) {
+ if len(item.raw) > 0 {
+ return item.raw, nil
+ }
+ type plain ContentItem
+ return json.Marshal(plain(item))
+}
+
+func (item *ContentItem) UnmarshalJSON(data []byte) error {
+ type plain ContentItem
+ var decoded plain
+ if err := json.Unmarshal(data, &decoded); err != nil {
+ return err
+ }
+ *item = ContentItem(decoded)
+ item.raw = append(item.raw[:0], data...)
+ return nil
}
diff --git a/kernel/mcp/tools/validation.go b/kernel/mcp/tools/validation.go
index fc0bcb1396..ee016273b4 100644
--- a/kernel/mcp/tools/validation.go
+++ b/kernel/mcp/tools/validation.go
@@ -27,20 +27,20 @@ import (
)
const (
- maxToolSchemaBytes = 1 << 20
- maxToolSchemaDepth = 64
- maxToolSchemaNodes = 16 << 10
- maxToolValueBytes = 8 << 20
- maxToolValueDepth = 128
- maxToolValueNodes = 256 << 10
- toolValidationTime = 2 * time.Second
+ maxToolSchemaBytes = 1 << 20
+ maxToolSchemaDepth = 64
+ maxToolSchemaNodes = 16 << 10
+ maxToolValueBytes = 8 << 20
+ maxToolValueDepth = 128
+ maxToolValueNodes = 256 << 10
+ toolValidationTime = 2 * time.Second
+ toolValidationConcurrency = 4
)
-var toolValidationSlots = make(chan struct{}, 4)
-
type ToolValidator struct {
- input *jsonschema.Resolved
- output *jsonschema.Resolved
+ input *jsonschema.Resolved
+ output *jsonschema.Resolved
+ validationSlots chan struct{}
}
func CompileToolValidator(tool *Tool) (*ToolValidator, error) {
@@ -59,7 +59,11 @@ func CompileToolValidator(tool *Tool) (*ToolValidator, error) {
return nil, fmt.Errorf("invalid output schema: %w", err)
}
}
- return &ToolValidator{input: input, output: output}, nil
+ return &ToolValidator{
+ input: input,
+ output: output,
+ validationSlots: make(chan struct{}, toolValidationConcurrency),
+ }, nil
}
func resolveToolSchema(schema ToolSchema, requireObject bool) (*jsonschema.Resolved, error) {
@@ -109,7 +113,7 @@ func (validator *ToolValidator) ValidateInputContext(ctx context.Context, argume
if err != nil {
return err
}
- return validateResolved(ctx, validator.input, value)
+ return validateResolved(ctx, validator.validationSlots, validator.input, value)
}
func (validator *ToolValidator) ValidateOutput(result CallToolResult) error {
@@ -127,7 +131,7 @@ func (validator *ToolValidator) ValidateOutputContext(ctx context.Context, resul
if err != nil {
return fmt.Errorf("prepare structured content: %w", err)
}
- return validateResolved(ctx, validator.output, value)
+ return validateResolved(ctx, validator.validationSlots, validator.output, value)
}
func prepareValidationValue(value any) (any, error) {
@@ -151,7 +155,7 @@ func prepareValidationValue(value any) (any, error) {
return canonical, nil
}
-func validateResolved(ctx context.Context, schema *jsonschema.Resolved, value any) error {
+func validateResolved(ctx context.Context, validationSlots chan struct{}, schema *jsonschema.Resolved, value any) error {
if ctx == nil {
ctx = context.Background()
}
@@ -159,7 +163,7 @@ func validateResolved(ctx context.Context, schema *jsonschema.Resolved, value an
defer timer.Stop()
select {
- case toolValidationSlots <- struct{}{}:
+ case validationSlots <- struct{}{}:
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
@@ -169,7 +173,7 @@ func validateResolved(ctx context.Context, schema *jsonschema.Resolved, value an
result := make(chan error, 1)
go func() {
err := schema.Validate(value)
- <-toolValidationSlots
+ <-validationSlots
result <- err
}()
diff --git a/kernel/mcp/tools/validation_test.go b/kernel/mcp/tools/validation_test.go
index c189bcd1f7..311d91f982 100644
--- a/kernel/mcp/tools/validation_test.go
+++ b/kernel/mcp/tools/validation_test.go
@@ -16,7 +16,12 @@
package tools
-import "testing"
+import (
+ "context"
+ "errors"
+ "testing"
+ "time"
+)
func TestToolValidatorValidatesInputAndOutput(t *testing.T) {
validator, err := CompileToolValidator(&Tool{
@@ -130,3 +135,37 @@ func TestToolValidatorRejectsExcessiveValueDepth(t *testing.T) {
t.Fatal("expected excessive value depth to fail")
}
}
+
+func TestToolValidatorTimeoutIsIsolatedPerTool(t *testing.T) {
+ blocked, err := CompileToolValidator(&Tool{
+ Name: "blocked",
+ InputSchema: ToolSchema{Type: "object"},
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ healthy, err := CompileToolValidator(&Tool{
+ Name: "healthy",
+ InputSchema: ToolSchema{Type: "object"},
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ for range cap(blocked.validationSlots) {
+ blocked.validationSlots <- struct{}{}
+ }
+ t.Cleanup(func() {
+ for range cap(blocked.validationSlots) {
+ <-blocked.validationSlots
+ }
+ })
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
+ defer cancel()
+ if err = blocked.ValidateInputContext(ctx, map[string]any{}); !errors.Is(err, context.DeadlineExceeded) {
+ t.Fatalf("unexpected blocked validation result: %v", err)
+ }
+ if err = healthy.ValidateInput(map[string]any{}); err != nil {
+ t.Fatalf("blocked validator affected another tool: %v", err)
+ }
+}