In the Hello World example, you used yield with AgentMessage to send textual data to the agent consumer. This concept has two important parts:
  1. Yielding data: You can yield data from your agent implementation, which gets sent to the client
  2. AgentMessage wrapper: AgentMessage is a convenience wrapper around A2A Message that simplifies common use cases. Think of responding with text to the client.

BeeAI SDK Message Types

The BeeAI SDK simplifies development by allowing you to yield different types of data. You can use convenient SDK constructs or direct A2A components.

Convenience Wrappers

AgentMessage

The most common way to respond with text. It’s a convenience wrapper around A2A Message that makes it easy to create responses:
yield AgentMessage(text="This is my text", metadata={"foo": "bar"})

Plain strings

Simple strings are automatically converted to textual A2A Message objects:
yield "Hello, world!"

Plain dict

Dictionaries sends Message containing DataPart
yield {"status": "processing", "progress": 50}

AgentArtifact

Same as AgentMessage but simplifies work with Artifacts.

Direct A2A Components

For more advanced use cases, you can yield direct A2A protocol components.
While it’s perfectly fine to yield plain A2A Components, the BeeAI platform forms opinions on communication to support great UX in the GUI. For the best user experience, we recommend using the convenience wrappers when possible.
Feel free to check the A2A Key Concepts page to understand all the structures thoroughly.

Message

The basic communication unit in the A2A protocol, representing a single turn in a conversation.
import uuid
from a2a.types import ( Message, TextPart )

yield Message(role="agent", message_id=str(uuid.uuid4()), parts=[TextPart(text="Hello from the agent!")])

Part

The fundamental unit of content. For example, a TextPart contains text data. A Message consists of multiple Part objects. Can be any of TextPart, FilePart, or DataPart.
from a2a.types import ( TextPart )

yield TextPart(text="Hello from the agent!")

Artifact

Tangible outputs produced by the agent, such as documents, files, or other generated content.
import uuid
from a2a.types import Artifact, FilePart, FileWithUri

yield Artifact(
    artifact_id=str(uuid.uuid4()),
    parts=[FilePart(file=FileWithUri(uri="https://www.ibm.com/us-en", mime_type="text/html", name="IBM Website"))],
)

TaskStatus

A stateful unit of work that can annotate a transaction spanning multiple messages. The task state can change over time as the agent progresses.
import uuid
from a2a.types import TaskStatus, TextPart, Message, TaskState

yield TaskStatus(
    message=Message(message_id=str(uuid.uuid4()), role="agent", parts=[TextPart(text="Please provide some input.")]),
    state=TaskState.input_required,
)