this.messages is a persistent, ordered log of AgentMessage objects stored in the
actor’s KV. It is per-actor — each idFromName("user-123") gets its own independent
history.
Framework adapters
this.messages can convert history to the format expected by popular LLM SDKs:
toAnthropic() omits system messages: the Anthropic Messages API takes the system
prompt as a top-level system parameter, not as a conversation message. Pass it on the
request yourself.
The toOpenAI() payload feeds Telnyx Inference directly —
env.TELNYX.ai.openai.chat.createCompletion({ model, messages }) on the
pre-authenticated Telnyx API binding, or any
OpenAI-compatible endpoint over HTTP. See
Calling LLMs for both wiring patterns.
Message shape