memory block is written by set memory, or by the wizard. It becomes spec.memory in .telnyx/index.ts, and each conversation’s memory is built on demand by memory() in managed/agent.ts:
this.getState() is getState(). Its from is the sender that admit wrote. On a fresh instance it returns initialState(), which the class defines as {}.
this.env.TELNYX is the Telnyx binding of the instance’s env. Both calls on Agent Memory go through it, and without it there is no memory.
The conversation key is the caller’s number on a call, set by the voice class, or the sender of the last text or email, held in state. A conversation with neither, such as one reached by invoke or chat, is keyed on its own name, which conversationName() decodes from the instance’s id:
decodeAgentName(this.ctx.id) is decodeAgentName().
this.ctx.idis the instance’s actor id, fromctx, which the mount encoded from the conversation’s name.- It returns that name, such as
aliceforinvoke --conversation alice. - It throws for an id the mount did not make. The key is then undefined, and the conversation has no memory.
createAgentMemory in managed/memory.ts resolves {{conversation}} in the profile template to that key and makes two calls on Agent Memory.
- The summary is read at the start, bounded by
CARD_TIMEOUT_MSof one second. - The conversation is pushed at the end.