Agent skill
a2a-messages-parts
Implement A2A messages and parts — TextPart, FilePart, DataPart, message roles, metadata, and content negotiation. Use when building message construction, parsing, or content type handling in A2A agents.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/a2a-messages-parts
SKILL.md
A2A Messages and Parts
Before writing code
Fetch live docs:
- Fetch
https://a2a-protocol.org/latest/specification/for the Message and Part schemas - Web-search
site:github.com a2aproject A2A message parts TextPart FilePart DataPartfor schema details - Web-search
site:github.com a2aproject a2a-samples messagefor message construction examples - Fetch SDK docs for message builder classes and part types
Conceptual Architecture
What Messages Are
Messages are the communication units between agents in A2A. Each message belongs to a task and contains one or more Parts that carry the actual content. Messages have roles indicating direction.
Message Structure
- role —
user(from client agent) oragent(from server agent) - parts — Array of Part objects (the actual content)
- metadata — Optional key-value pairs for custom data
Three Part Types
TextPart
Plain text or markdown content.
- kind:
"text" - text: The text content string
- metadata: Optional key-value pairs
Use for: Natural language instructions, responses, explanations, formatted output.
FilePart
File content, either inline or by reference.
- kind:
"file" - file: Object containing either:
- bytes: Base64-encoded file content + mimeType
- uri: URL to the file + optional mimeType
- metadata: Optional key-value pairs
Use for: Images, documents, code files, generated files, binary data.
DataPart
Structured JSON data.
- kind:
"data" - data: Any valid JSON value (object, array, string, number, etc.)
- metadata: Optional key-value pairs
Use for: Structured results, API responses, configuration, machine-readable output.
Content Negotiation
Agents declare supported MIME types in their Agent Card:
- defaultInputModes — What the agent can receive
- defaultOutputModes — What the agent can produce
Clients can specify preferred output modes in the request:
- acceptedOutputModes — MIME types the client wants (in the configuration object)
If there's a mismatch, the server returns error -32005 (incompatible content types).
Message Flow in a Task
Client message (role: user) → Server creates/continues task
Server response (role: agent) → Client processes result
Client follow-up (role: user) → Server continues task (multi-turn)
Server final (role: agent) → Task reaches terminal state
Composing Rich Messages
Messages can contain multiple parts of mixed types:
{
"role": "user",
"parts": [
{ "kind": "text", "text": "Analyze this image and provide structured results" },
{ "kind": "file", "file": { "uri": "https://example.com/chart.png", "mimeType": "image/png" } }
]
}
Best Practices
- Use TextPart for natural language, DataPart for structured data — don't serialize JSON into TextPart
- Include mimeType with FileParts for proper content handling
- Prefer URI-based FileParts over inline bytes for large files
- Validate that message parts match the agent's declared input modes
- Keep metadata lightweight — don't store large payloads there
- For multi-modal interactions, combine TextParts with FileParts in the same message
- Parse all part types when receiving messages — don't assume text-only
Fetch the specification for exact Part schemas, all fields, metadata conventions, and content type handling rules before implementing.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?