Empties the field: the transcript and every stored name go together.
There is no way to drop only the transcript, deliberately. State stored by put(...) describes
the conversation it was stored alongside — which reviewer was asked, which record was proposed —
so keeping it beside a conversation that no longer exists is how a resumed run acts on an answer
to a question it never asked.
Reads back a value stored by put(...), or null when the name was never stored.
The name to read.
Stores one named value beside the transcript. The value is anything JSON.stringify accepts;
null removes the name.
store.put("awaitingReviewer", user.id());
The name to store under.
The value, or null to remove the name.
Seeds the agent from the stored transcript, and answers whether there was one.
false is the first run — the field is empty, the agent keeps the empty transcript it was built
with, and the script carries on as it would have. That is the whole reason this returns anything:
a script that needs to tell a fresh conversation from a resumed one can, without reading the
field itself.
The agent to seed.
Writes the agent's transcript into the field, leaving any state kept by put(...) untouched.
The value is written through the field the same way assigning to it is: what saves the entry in the surrounding script is what makes it durable.
const store = B.ai.state(curEntry.fields.agentState);
const agent = B.ai.agent({tools, systemPrompt});
store.restore(agent);
const result = agent.sendMessage(B.net.request.parameter("q"));
store.save(agent);
The agent whose transcript to store.
Keeps an AI agent's transcript, and any state a script wants beside it, on a Relate memo or serializable field so a conversation survives across executions.
Example: ```javascript
const store = B.ai.state(curEntry.fields.agentState); const agent = B.ai.agent({ tools: [proposeEntry], systemPrompt: PROMPT });
if (!store.restore(agent)) { agent.sendMessage(B.net.request.parameter("q")); // first run: nothing was waiting } store.put("reviewedBy", B.user.id); // anything the script wants beside the transcript store.save(agent);