Skip to main content
A chat container receives an operator prompt, calls a model or tool system, and streams structured responses back to a Mythic AI chat channel. The Python mythic-container library provides the v4 chat base class and response helpers.

Minimal container

One chat(msg) call handles one Mythic request. An approval or input continuation arrives as a new ChatRequest, not as a callback into the old coroutine.

Request shape

Never copy secrets or Bearer tokens into response content or metadata.

Streaming response shape

Reuse one response_key for updates to the same visible block. Use another key for tool cards, approval cards, or a separate final answer.

Human-in-the-loop and tools

Well-known metadata.special_type values let Mythic render native UI:
  • tool_use for tool progress and lazily fetched full output;
  • mcp_tool_confirmation for an approval before a write-capable MCP call;
  • input_requested for free-form or choice-based operator input;
  • subagent for delegated work grouped by delegation_id.
When a tool requires approval, finish the current request after sending the confirmation card. If approved, Mythic sends a new request containing the confirmed tool call. Rebuild typed configuration and run only that approved call.

Cancellation

The library tracks active request tasks and cancels them when Mythic sends a cancellation. Provider clients should propagate cancellation to their HTTP/streaming call and avoid sending a second terminal completion after cancellation. For a complete reference implementation, use the basic_chat example and the CHAT_CONTAINERS.md guide in the MythicContainerPyPi repository matching your installed library version.