> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Event • AI Agent SDK

> ContextEvent: A single context event for replay.

# ContextEvent

> Defined in the [**Context Events**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/context_events.md) module.

AI Agent

A single context event for replay.

Represents a discrete change in agent context during execution.
Designed for minimal memory footprint and fast serialization.

Attributes:
event\_type: Type of context event
timestamp: Unix timestamp when event occurred
session\_id: Session identifier for grouping events
agent\_name: Name of the agent (if applicable)
sequence\_num: Sequential event number within session
messages\_count: Number of messages in context at this point
tokens\_used: Tokens used in context at this point
tokens\_budget: Total token budget available
data: Event-specific data (tool args, message content, etc.)
branch\_id: Optional branch identifier for parallel execution tracking
prompt\_tokens: Number of tokens in the prompt/request
completion\_tokens: Number of tokens in the completion/response
cost\_usd: Estimated cost in USD for this event
content\_hash: SHA256 hash of content for duplicate detection
run\_id: The team/flow/recorded run this event belongs to (1.1)
parent\_seq: sequence\_num of the enclosing (or, on \*\_end, the closed)
\*\_start event (1.1)
node\_id: Graph node the event concerns, e.g. `agent:Writer` (1.1)

## Properties

**event\_type** `ContextEventType`

No description available.

**timestamp** `float`

No description available.

**session\_id** `str`

No description available.

**agent\_name** `Optional[str]`

No description available.

**sequence\_num** `int`

No description available.

**messages\_count** `int`

No description available.

**tokens\_used** `int`

No description available.

**tokens\_budget** `int`

No description available.

**data** `Dict[str, Any]`

No description available.

**branch\_id** `Optional[str]`

No description available.

**prompt\_tokens** `int`

No description available.

**completion\_tokens** `int`

No description available.

**cost\_usd** `float`

No description available.

**content\_hash** `Optional[str]`

No description available.

**run\_id** `Optional[str]`

No description available.

**parent\_seq** `Optional[int]`

No description available.

**node\_id** `Optional[str]`

No description available.

> [accordion] Internal & Generic Methods
>
> * **from\_dict**: Create ContextEvent from dictionary.
> * **to\_dict**: Convert to dictionary for serialization.
> * **to\_json**: Convert to JSON string.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/trace/context_events.py#L364)
>
> `praisonaiagents/trace/context_events.py` at line 364

***

## Related Documentation

> [card] [Context Concept](https://praison.ai/docs/docs/concepts/context)

> [card] [Context Management](https://praison.ai/docs/docs/features/context-management)

> [card] [Context Strategies](https://praison.ai/docs/docs/features/context-strategies)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.