Skip to main content
Message (Msg) is the basic data structure in AgentScope, responsible for exchanging information among agents, users, and tools. Its basic fields include:
FieldDescription
idUnique identifier for the message
nameThe name of the message sender
roleThe role of the message sender (“user”, “assistant”, “system”)
contentThe content of the message, which can be text, image, video, audio, tool calls, tool results, etc.
timestampThe time when the message was created
metadataAdditional information about the message, such as tool calls, reasoning traces, etc.
The content field can be a plain string for simple text messages, or a list of content blocks for multimodal and tool call messages. Each content block is a dictionary with a type field indicating the content type.
Supported content block types:
TypeExample
text{"type": "text", "text": "Hello AgentScope!"}
thinking{"type": "thinking", "thinking": "Hmm, let me think..."}
image{"type": "image", "source": {"type": "url", "url": "https://xxx/image.jpg"}}
video{"type": "video", "source": {"type": "url", "url": "https://xxx/video.mp4"}}
audio{"type": "audio", "source": {"type": "url", "url": "https://xxx/audio.mp3"}}
tool_use{"type": "tool_use", "id": "xxxx", "name": "search", "input": {"query": "..."}}
tool_result{"type": "tool_result", "id": "xxxx", "name": "search", "output": "..."}
Quick examples:
from agentscope.message import Msg

# A simple text message
msg = Msg(name="Friday", content="Hello, I'm your assistant!", role="assistant")

# Multimodal message
msg = Msg(
    name="Bob",
    content=[
        {"type": "text", "text": "How about this image?"},
        {"type": "image", "source": {"type": "url", "url": "https://example.com/image.jpg"}},
    ],
    role="user",
)

# Tool call message
msg = Msg(
    name="Alice",
    content=[
        {
            "type": "tool_use",
            "id": "xxxx",
            "name": "search",
            "input": {"query": "What's the weather today?"}
        }
    ],
    role="user",
)