Skip to content

fix(deps): bump cogito to fix MCP image-content panic (#10101)#10105

Open
Dennisadira wants to merge 3 commits into
mudler:masterfrom
Dennisadira:fix/mcp-image-content-panic
Open

fix(deps): bump cogito to fix MCP image-content panic (#10101)#10105
Dennisadira wants to merge 3 commits into
mudler:masterfrom
Dennisadira:fix/mcp-image-content-panic

Conversation

@Dennisadira
Copy link
Copy Markdown
Contributor

Summary

Fixes #10101 — the API container crashes with a Go panic whenever an MCP tool returns non-text content (images, audio, resources):

panic: interface conversion: mcp.Content is *mcp.ImageContent, not *mcp.TextContent
github.com/mudler/cogito@v0.9.5.../mcp.go:52

The panic happens on an agent goroutine with no recover, which takes the whole process down.

Root cause: mcpTool.Execute in cogito unconditionally asserted every mcp.Content item to *mcp.TextContent. Any tool returning image/audio/resource content (e.g. the get_map_image tool in osmmcp, NASA MCP image tools) triggers the panic.

Fix: mudler/cogito#50 replaces the hard assertion with a type switch. Non-text blocks are summarised with descriptive markers ([image content (image/png), N bytes] etc.) so the model receives something useful instead of crashing.

This PR bumps github.com/mudler/cogito from v0.9.5-0.20260315222927-63abdec7189b to v0.9.5-0.20260531081147-2c13b6ac29cf (the tip of the fix/mcp-image-content-panic branch in cogito, which is the revision from mudler/cogito#50).

Test plan

  • go build github.com/mudler/cogito clean on the new pseudo-version
  • go mod tidy produces a clean go.sum
  • Manual: add an MCP server that returns image content (e.g. osmmcp) to an agent and confirm the agent returns a result instead of crashing

🤖 Generated with Claude Code

Dennisadira and others added 3 commits May 21, 2026 23:22
Closes mudler#1649.

Mirror of the existing /v1/tokenize path, requested by @benniekiss in
the issue thread for "complete API workflow" use cases that need to
turn token IDs back into text without local processing.

- Add Detokenize gRPC RPC with DetokenizeRequest{tokens} /
  DetokenizeResponse{content} messages.
- Implement in the llama.cpp backend using common_token_to_piece, the
  same primitive TokenizeString already uses internally.
- Other backends inherit the default Unimplemented from base.Base, in
  line with how Detect, Rerank, etc. are gated per-backend.
- Wire up the Go gRPC interface, server, client, and in-process embed
  wrapper alongside their TokenizeString counterparts.
- Add the schema types, ModelDetokenize wrapper, HTTP handler, route
  registration, RouteFeatureRegistry entry (gated by FeatureTokenize so
  no new feature flag is needed), and the discovery map entry under
  ai_functions.
- Regenerated swagger reflects the new endpoint and types.
- Update authentication.md to list /v1/detokenize alongside /v1/tokenize.

Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Adira Denis Muhando <dennisadira@gmail.com>
Add Detokenize to the mock gRPC backend and wire up two e2e tests in
the MockBackend suite: one that posts known token IDs and asserts a
non-empty content response, and a round-trip that tokenizes first then
detokenizes the returned IDs.

Addresses reviewer feedback on mudler#9620.

Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Adira Denis Muhando <dennisadira@gmail.com>
Bumps github.com/mudler/cogito from
  v0.9.5-0.20260315222927-63abdec7189b
to
  v0.9.5-0.20260531081147-2c13b6ac29cf

The new revision contains mudler/cogito#50 which replaces the hard
*mcp.TextContent type assertion in mcpTool.Execute with a type switch.
Any MCP tool that returns image, audio, resource-link, or
embedded-resource content previously caused:

  panic: interface conversion: mcp.Content is *mcp.ImageContent, not *mcp.TextContent

bringing down the entire host process.  The new code summarises
non-text blocks with a descriptive marker so the model receives
something useful without crashing.

Closes mudler#10101

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mudler
Copy link
Copy Markdown
Owner

mudler commented May 31, 2026

@Dennisadira please rebase, lots of code which is not part of this PR shows up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api crashes when an mcp returns an image

2 participants