diff --git a/core/http/endpoints/localai/mcp.go b/core/http/endpoints/localai/mcp.go index f23b00e4fabb..b9f22667bef2 100644 --- a/core/http/endpoints/localai/mcp.go +++ b/core/http/endpoints/localai/mcp.go @@ -143,9 +143,11 @@ func MCPStreamEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, eval cogito.WithReasoningCallback(func(s string) { log.Debug().Msgf("[model agent] [model: %s] Reasoning: %s", config.Name, s) }), - cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool { + cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision { log.Debug().Str("model", config.Name).Str("tool", t.Name).Str("reasoning", t.Reasoning).Interface("arguments", t.Arguments).Msg("[model agent] Tool call") - return true + return cogito.ToolCallDecision{ + Approved: true, + } }), cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) { log.Debug().Str("model", config.Name).Str("tool", t.Name).Str("result", t.Result).Interface("tool_arguments", t.ToolArguments).Msg("[model agent] Tool call result") @@ -206,14 +208,16 @@ func MCPStreamEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, eval } } - toolCallCallback := func(t *cogito.ToolChoice) bool { + toolCallCallback := func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision { events <- MCPToolCallEvent{ Type: "tool_call", Name: t.Name, Arguments: t.Arguments, Reasoning: t.Reasoning, } - return true + return cogito.ToolCallDecision{ + Approved: true, + } } toolCallResultCallback := func(t cogito.ToolStatus) { diff --git a/core/http/endpoints/openai/mcp.go b/core/http/endpoints/openai/mcp.go index 72fab3c6a20a..6b01975bc9fd 100644 --- a/core/http/endpoints/openai/mcp.go +++ b/core/http/endpoints/openai/mcp.go @@ -107,9 +107,11 @@ func MCPCompletionEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, cogito.WithReasoningCallback(func(s string) { log.Debug().Msgf("[model agent] [model: %s] Reasoning: %s", config.Name, s) }), - cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool { + cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision { log.Debug().Msgf("[model agent] [model: %s] Tool call: %s, reasoning: %s, arguments: %+v", config.Name, t.Name, t.Reasoning, t.Arguments) - return true + return cogito.ToolCallDecision{ + Approved: true, + } }), cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) { log.Debug().Msgf("[model agent] [model: %s] Tool call result: %s, result: %s, tool arguments: %+v", config.Name, t.Name, t.Result, t.ToolArguments) diff --git a/core/services/agent_jobs.go b/core/services/agent_jobs.go index 0693400d5956..4b0db314f7cd 100644 --- a/core/services/agent_jobs.go +++ b/core/services/agent_jobs.go @@ -838,7 +838,7 @@ func (s *AgentJobService) executeJobInternal(job schema.Job, task schema.Task, c job.Traces = append(job.Traces, trace) s.jobs.Set(job.ID, job) }), - cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool { + cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision { log.Debug().Str("job_id", job.ID).Str("model", modelConfig.Name). Str("tool", t.Name).Str("reasoning", t.Reasoning).Interface("arguments", t.Arguments). Msg("Tool call") @@ -856,7 +856,9 @@ func (s *AgentJobService) executeJobInternal(job schema.Job, task schema.Task, c } job.Traces = append(job.Traces, trace) s.jobs.Set(job.ID, job) - return true + return cogito.ToolCallDecision{ + Approved: true, + } }), cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) { log.Debug().Str("job_id", job.ID).Str("model", modelConfig.Name). diff --git a/go.mod b/go.mod index 4f720c46a71a..0d407c91ee78 100644 --- a/go.mod +++ b/go.mod @@ -30,9 +30,10 @@ require ( github.com/mholt/archiver/v3 v3.5.1 github.com/microcosm-cc/bluemonday v1.0.27 github.com/modelcontextprotocol/go-sdk v1.1.0 - github.com/mudler/cogito v0.6.0 + github.com/mudler/cogito v0.7.1 github.com/mudler/edgevpn v0.31.1 github.com/mudler/go-processmanager v0.0.0-20240820160718-8b802d3ecf82 + github.com/mudler/memory v0.0.0-20251216220809-d1256471a6c2 github.com/onsi/ginkgo/v2 v2.27.3 github.com/onsi/gomega v1.38.3 github.com/otiai10/copy v1.14.1 @@ -65,7 +66,6 @@ require ( require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/labstack/gommon v0.4.2 // indirect - github.com/mudler/memory v0.0.0-20251216220809-d1256471a6c2 // indirect github.com/swaggo/files/v2 v2.0.2 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect ) @@ -273,7 +273,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index e236a49d4ef2..bb8e9cbba7eb 100644 --- a/go.sum +++ b/go.sum @@ -506,8 +506,8 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/mudler/cogito v0.6.0 h1:jn6gO18Wcyfhcfe1CPjl0FCG3S1LBLrLf7LVPxpRPic= -github.com/mudler/cogito v0.6.0/go.mod h1:2uhEElCTq8eXSsqJ1JF01oA5h9niXSELVKqCF1PqjEw= +github.com/mudler/cogito v0.7.1 h1:WJyRh6AuesPqoB7pZ/ow6HB6hL8VSSuJdR2VfbZ2E2U= +github.com/mudler/cogito v0.7.1/go.mod h1:2uhEElCTq8eXSsqJ1JF01oA5h9niXSELVKqCF1PqjEw= github.com/mudler/edgevpn v0.31.1 h1:7qegiDWd0kAg6ljhNHxqvp8hbo/6BbzSdbb7/2WZfiY= github.com/mudler/edgevpn v0.31.1/go.mod h1:ftV5B0nKFzm4R8vR80UYnCb2nf7lxCRgAALxUEEgCf8= github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc h1:RxwneJl1VgvikiX28EkpdAyL4yQVnJMrbquKospjHyA=