Skip to content

Commit 8b6f443

Browse files
authored
chore(deps): bump cogito to latest and adapt API changes (#7655)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 626057b commit 8b6f443

5 files changed

Lines changed: 21 additions & 13 deletions

File tree

core/http/endpoints/localai/mcp.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ func MCPStreamEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, eval
143143
cogito.WithReasoningCallback(func(s string) {
144144
log.Debug().Msgf("[model agent] [model: %s] Reasoning: %s", config.Name, s)
145145
}),
146-
cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool {
146+
cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision {
147147
log.Debug().Str("model", config.Name).Str("tool", t.Name).Str("reasoning", t.Reasoning).Interface("arguments", t.Arguments).Msg("[model agent] Tool call")
148-
return true
148+
return cogito.ToolCallDecision{
149+
Approved: true,
150+
}
149151
}),
150152
cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) {
151153
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
206208
}
207209
}
208210

209-
toolCallCallback := func(t *cogito.ToolChoice) bool {
211+
toolCallCallback := func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision {
210212
events <- MCPToolCallEvent{
211213
Type: "tool_call",
212214
Name: t.Name,
213215
Arguments: t.Arguments,
214216
Reasoning: t.Reasoning,
215217
}
216-
return true
218+
return cogito.ToolCallDecision{
219+
Approved: true,
220+
}
217221
}
218222

219223
toolCallResultCallback := func(t cogito.ToolStatus) {

core/http/endpoints/openai/mcp.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ func MCPCompletionEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader,
107107
cogito.WithReasoningCallback(func(s string) {
108108
log.Debug().Msgf("[model agent] [model: %s] Reasoning: %s", config.Name, s)
109109
}),
110-
cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool {
110+
cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision {
111111
log.Debug().Msgf("[model agent] [model: %s] Tool call: %s, reasoning: %s, arguments: %+v", config.Name, t.Name, t.Reasoning, t.Arguments)
112-
return true
112+
return cogito.ToolCallDecision{
113+
Approved: true,
114+
}
113115
}),
114116
cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) {
115117
log.Debug().Msgf("[model agent] [model: %s] Tool call result: %s, result: %s, tool arguments: %+v", config.Name, t.Name, t.Result, t.ToolArguments)

core/services/agent_jobs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ func (s *AgentJobService) executeJobInternal(job schema.Job, task schema.Task, c
838838
job.Traces = append(job.Traces, trace)
839839
s.jobs.Set(job.ID, job)
840840
}),
841-
cogito.WithToolCallBack(func(t *cogito.ToolChoice) bool {
841+
cogito.WithToolCallBack(func(t *cogito.ToolChoice, state *cogito.SessionState) cogito.ToolCallDecision {
842842
log.Debug().Str("job_id", job.ID).Str("model", modelConfig.Name).
843843
Str("tool", t.Name).Str("reasoning", t.Reasoning).Interface("arguments", t.Arguments).
844844
Msg("Tool call")
@@ -856,7 +856,9 @@ func (s *AgentJobService) executeJobInternal(job schema.Job, task schema.Task, c
856856
}
857857
job.Traces = append(job.Traces, trace)
858858
s.jobs.Set(job.ID, job)
859-
return true
859+
return cogito.ToolCallDecision{
860+
Approved: true,
861+
}
860862
}),
861863
cogito.WithToolCallResultCallback(func(t cogito.ToolStatus) {
862864
log.Debug().Str("job_id", job.ID).Str("model", modelConfig.Name).

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ require (
3030
github.com/mholt/archiver/v3 v3.5.1
3131
github.com/microcosm-cc/bluemonday v1.0.27
3232
github.com/modelcontextprotocol/go-sdk v1.1.0
33-
github.com/mudler/cogito v0.6.0
33+
github.com/mudler/cogito v0.7.1
3434
github.com/mudler/edgevpn v0.31.1
3535
github.com/mudler/go-processmanager v0.0.0-20240820160718-8b802d3ecf82
36+
github.com/mudler/memory v0.0.0-20251216220809-d1256471a6c2
3637
github.com/onsi/ginkgo/v2 v2.27.3
3738
github.com/onsi/gomega v1.38.3
3839
github.com/otiai10/copy v1.14.1
@@ -65,7 +66,6 @@ require (
6566
require (
6667
github.com/ghodss/yaml v1.0.0 // indirect
6768
github.com/labstack/gommon v0.4.2 // indirect
68-
github.com/mudler/memory v0.0.0-20251216220809-d1256471a6c2 // indirect
6969
github.com/swaggo/files/v2 v2.0.2 // indirect
7070
github.com/valyala/fasttemplate v1.2.2 // indirect
7171
)
@@ -273,7 +273,7 @@ require (
273273
github.com/opencontainers/go-digest v1.0.0 // indirect
274274
github.com/opencontainers/image-spec v1.1.1
275275
github.com/opentracing/opentracing-go v1.2.0 // indirect
276-
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
276+
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
277277
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
278278
github.com/pierrec/lz4/v4 v4.1.2 // indirect
279279
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P
506506
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
507507
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
508508
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
509-
github.com/mudler/cogito v0.6.0 h1:jn6gO18Wcyfhcfe1CPjl0FCG3S1LBLrLf7LVPxpRPic=
510-
github.com/mudler/cogito v0.6.0/go.mod h1:2uhEElCTq8eXSsqJ1JF01oA5h9niXSELVKqCF1PqjEw=
509+
github.com/mudler/cogito v0.7.1 h1:WJyRh6AuesPqoB7pZ/ow6HB6hL8VSSuJdR2VfbZ2E2U=
510+
github.com/mudler/cogito v0.7.1/go.mod h1:2uhEElCTq8eXSsqJ1JF01oA5h9niXSELVKqCF1PqjEw=
511511
github.com/mudler/edgevpn v0.31.1 h1:7qegiDWd0kAg6ljhNHxqvp8hbo/6BbzSdbb7/2WZfiY=
512512
github.com/mudler/edgevpn v0.31.1/go.mod h1:ftV5B0nKFzm4R8vR80UYnCb2nf7lxCRgAALxUEEgCf8=
513513
github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc h1:RxwneJl1VgvikiX28EkpdAyL4yQVnJMrbquKospjHyA=

0 commit comments

Comments
 (0)