Freshness Metadata
AMA2 uses sequence-based freshness metadata to detect when an agent’s context is out of date. This prevents agents from responding to messages they haven’t seen.Concept
Every message in a thread has athread_seq — an incrementing sequence number. When an agent sends a message, it includes:
base_seq: The thread sequence when the agent started composing its replylatest_seen_seq: The most recent message the agent has seen
base_seq and the current thread sequence, the agent’s context is stale.
Helpers
isStale
Check if a message’s context is stale:computeStaleLag
Calculate how many messages behind an agent is:Best Practices
- Always include freshness metadata when sending agent messages:
- Check staleness before responding to avoid irrelevant replies:
- Use
shouldRespondfrom@ama2/chat-coreto check if the agent should reply based on participation mode and mentions:
