Key Identifiers
AdCP uses two distinct identifiers for different purposes:context_id vs task_id
| Identifier | Purpose | Lifespan | Scope |
|---|---|---|---|
| context_id | Conversation/session continuity | ~1 hour | Across multiple task calls |
| task_id | Tracking specific operations | Until completion (hours to days) | Single operation |
- Comes from the protocol layer (built into A2A, manual in MCP)
- Provides conversation history and session continuity
- Used for maintaining state across multiple task calls
- Expires after conversation timeout (typically 1 hour)
- Specific to individual requests that could be asynchronous
- Lives beyond the conversation
- Used for tracking operation progress over time
- Persists until the task completes (may be days for complex media buys)
- Can be referenced across different conversations or sessions
Usage Example
Protocol Differences
- A2A: Context is handled automatically by the protocol
- MCP: Requires manual context_id management
A2A Context (Automatic)
A2A handles sessions natively - you don’t need to manage context:MCP Context (Manual)
MCP requires explicit context management to maintain state:MCP Context Management Pattern
MCP Agent-Side: Session ID Fallback
Many MCP clients (ChatGPT, Claude) don’t passcontext_id. Agents should use the transport’s session ID as a fallback to enable automatic session persistence:
What Context Maintains
Thecontext_id maintains conversation state, regardless of protocol:
- Current media buy and products being discussed
- Search results and applied filters
- Conversation history and user intent
- User preferences expressed in the session
- Workflow state and temporary decisions
task_id, not context_id.
Extension Fields (ext)
Extension fields enable platform-specific functionality while maintaining protocol compatibility.
Schema Pattern
Extensions appear consistently across requests, responses, and domain objects:ext object:
- Is always optional (never required)
- Accepts any valid JSON structure
- Must be preserved by implementations (even unknown fields)
- Is not validated by AdCP schemas (implementation-specific validation allowed)
Namespacing (Critical)
Extensions MUST use vendor/platform namespacing:Application Context (context)
Context provides opaque correlation data that is echoed unchanged in responses and webhooks.
Key Properties
- Agents NEVER parse or use context to affect behavior
- Exists solely for the initiator’s internal tracking needs
- Echoed unchanged in responses and webhook payloads
Schema Pattern
Common Context Uses
- UI/Session tracking - Maintaining state across async operations
- Request correlation - Tracing requests through distributed systems
- Internal identifiers - Mapping to your internal data structures
- Organization context - Multi-tenant tracking
When to Use What
| Field | Purpose | Agent Reads? | Agent Modifies? |
|---|---|---|---|
context_id | Session continuity | Yes | Yes (creates/updates) |
task_id | Operation tracking | Yes | Yes (creates) |
ext | Platform-specific config | MAY | MAY add response data |
context | Opaque correlation | NEVER | NEVER |
Use ext when:
- Platform needs to parse the data
- Data MAY affect operational behavior
- Data represents platform-specific configuration
- Data should persist across operations
Use context when:
- Data is only for caller’s internal use
- Data should never affect agent behavior
- Data is for correlation/tracking only
- Data needs to be echoed unchanged
Best Practices
For A2A
- Let the protocol handle context
- Use contextId for explicit conversation threading
- Trust the session management
For MCP
- Always preserve context_id between calls
- Implement a session wrapper (see pattern above)
- Handle context expiration (1 hour timeout)
- Start fresh context for new workflows
- Agents: Use transport session ID as fallback when
context_idis not provided (see Session ID Fallback)
For Extensions
- Always namespace under vendor keys
- Document your extensions extensively
- Consider proposing standardization for common patterns
For Application Context
- Keep it opaque - don’t structure for agents to parse
- Avoid large payloads - context is echoed in every response
- Use for correlation only - never for operational data