Documentation Index
Fetch the complete documentation index at: https://docs.svantic.com/llms.txt
Use this file to discover all available pages before exploring further.
MessageBuilder
What it is
MessageBuilder is a fluent builder for A2A Message objects — the envelope that carries a user prompt plus any structured data (files, session context, form submissions, execution context) to a remote agent. An A2A message is usually two parts: a TextPart with the prompt and a DataPart with metadata. The builder makes assembling that second part ergonomic so you don’t hand-write DataPart JSON every time.
When to use it
- You’re calling another agent with a file attachment (PDF, image, document).
- You’re continuing a conversation (
with_context_id) and need to stay on the same session. - You’re replying to a form Svantic emitted (
with_action_data). - You need to route directly to a specific agent type (
with_target_agent) or hand the platform a learner-grade execution context.
remote.send(text) or remote.send_stream(text) instead — there’s nothing to build.
Functional usage
DataPart only if at least one metadata-carrying method was called — plain text passes through as a one-part message.
Constructor
text is the user-facing message string. It lands in the first TextPart of the resulting message.
Fluent methods
Every builder method returnsthis, so calls chain.
| Method | Purpose |
|---|---|
with_context_id(id) | Continue an existing A2A conversation. Typically the Svantic session_id. |
with_context(ctx) | Attach a free-form object describing the caller’s environment (page URL, datasource, active document, …). Forwarded to the remote handler on context. |
with_target_agent(name) | Route directly to a specific agent, bypassing the orchestrator. |
with_yolo_mode(yolo) | When true, tells the platform to auto-approve any plan the agent generates. Off by default. |
with_action_data(data) | Attach key: value form-submission data. Used when the user is replying to an A2UI form. |
with_file(file) / with_files(files) | Attach one or more FilePayload objects. Prefer setting file_id (from the platform’s file-upload endpoint) over inlining bytes. |
with_execution_context(ctx) | Attach a structured ExecutionContext for the learner. |
Terminal method
build(): Message
Returns an A2A Message. The message has:
- One
TextPartcarrying the constructor text. - One
DataPart(added only if any metadata-carrying builder method was called) with{ context, target_agent, yolo_mode, action_data, files, execution_context }— each key present only when set. - A fresh
messageId(UUID v4). role: 'user'.contextIdwhenwith_context_idwas called.
