A guide that remembers
Updated
An AI Memory names the record that keeps the guide’s memory between visits: a UI Switch turns it on and off, and the agent’s memory activity events update a label.
Flip Remember me: the label shows whether the guide keeps a memory, and in which record. Reading and writing memory happen during replies, which need the AI service; this preview does not have it, so a message you send shows a short error instead. Drag outside the panels to orbit the camera.
A guide that remembers
#pragma lifecycle(startup)
function startup() { const memory = findEntity('Guide').getComponent(AIMemoryComponent); const record = findEntity('Memory Record').getComponent(UILabelComponent); const activity = findEntity('Memory Activity').getComponent(UILabelComponent);
function show() { record.setProps({ text: memory.enabled ? `Kept in the record "${memory.props.persistable}"` : 'Off: nothing outlives this page', color: memory.enabled ? '#34d399' : '#9ca3af', }); }
on('memory/toggle', (event) => { if (event.eventType !== EventType.UISwitch.Change) return; memory.setEnabled(event.data.checked); log('memory', event.data.checked ? 'on' : 'off'); show(); });
on('guide:ai', (event) => { if (event.eventType === EventType.AIAgent.MemoryRead) activity.setProps({ text: 'Recalled what you said last time.' }); if (event.eventType === EventType.AIAgent.MemoryWritten) activity.setProps({ text: 'Saved something new to remember.' }); if (event.eventType === EventType.AIAgent.MemoryReadFailed || event.eventType === EventType.AIAgent.MemoryWriteFailed) { activity.setProps({ text: 'Memory is unavailable right now.' }); } });
log('memory record:', memory.props.persistable); show();}Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
AgentMemory.xrproj