How AI Agents Use Account History, ICP Rules and Playbooks Across Runs
An AI agent uses account history, ICP rules and playbooks across runs only if each one is stored where the next run will read it: account history as fields on the account record, ICP rules and playbooks as versioned files the agent reads at run time, and run-to-run bookkeeping (cooldowns, daily caps) in a key-value store with an expiry. Agent memory, the kind an agent writes for itself, is for soft facts and preferences, not for any of those three.
Each run of a scheduled agent starts empty, and where last night’s run wrote things down decides whether tonight’s can trust them. For what context means more broadly (knowledge, state, tools, memory), see building and contextualizing GTM agents. This post is narrower: the plumbing that makes run 2 aware of run 1.
Where each kind of state goes #
| What the next run needs | Store it in | Why not elsewhere |
|---|---|---|
| What we concluded about this account | Fields on the account record | Every other workflow, rep and report reads the record; a private memory is invisible |
| The ICP, disqualifiers, playbooks | A versioned repository the agent reads | A rule pasted into a prompt changes without review and cannot be traced to a verdict |
| ”Already did this recently”, daily caps | Key-value memory with an expiry | It must expire on its own; a field that never clears blocks the account forever |
| Preferences learned in conversation | Agent memory | Soft, per-agent, fine if wrong once; never the basis for touching a customer |
The failure to watch for is the second row ending up in the fourth: an agent “remembering” that you stopped selling to agencies. It will remember inconsistently, nobody can review the memory in a pull request, and when the rule changes back there is nothing to revert.
A worked example: nightly account research that does not repeat itself #
The job: every night, research newly assigned accounts, write a brief onto the account, never re-research an account inside 30 days, and stop at 200 briefs a day across the whole workspace. On Cargo, the agent and the workflow are code in a project.
The agent reads the account model and the context repository, and keeps its own memory for soft facts:
import { defineAgent } from "@cargo-ai/cdk";
export const researcher = defineAgent("researcher", {
connector: openai,
languageModel: "gpt-4o",
systemPrompt:
"Research accounts for the sales team. Name the ICP rule behind every finding. Never state a fact you did not read from a tool, the model or the context repository.",
capabilities: ["context", "memory", "webSearch"],
uses: [{ ref: accounts, readOnly: true }],
});
context gives the agent tools to map, search and read the workspace’s context repository, where defineContext({ path: "context" }) syncs your ICP and playbook markdown on every deploy. memory gives it a durable, agent-scoped memory it can write to and search across chats. readOnly keeps it from writing to accounts directly; the workflow does that.
The workflow carries the run-to-run state:
import { defineWorkflow } from "@cargo-ai/cdk";
import { z } from "zod";
import { researcher } from "../agents/researcher";
import { accounts } from "../models/accounts";
const RUBRIC_VERSION = "icp-2026-12"; // bump in the same PR as an ICP change
export const researchAccount = defineWorkflow(
"research-account",
{
input: z.object({ domain: z.string(), day: z.string() }), // day: run date, YYYY-MM-DD
output: z.unknown(),
uses: { researcher },
imports: { accounts, RUBRIC_VERSION },
},
({ input, uses, memory, model }) => {
const recent = memory.get({ key: input.domain });
if (recent.result !== null) {
return { skipped: "researched in the last 30 days" };
}
const today = memory.increment({
key: `briefs-${input.day}`,
scope: "workspace",
expiresIn: { value: 2, unit: "day" },
});
if (today.result > 200) {
return { skipped: "daily cap reached" };
}
const brief = uses.researcher({
prompt: `Research ${input.domain}. Read the ICP and playbooks in the context repository first, and name the ICP rule behind each finding.`,
}).answer;
model.upsert({
modelUuid: accounts.uuid,
matchingColumnSlug: "domain",
matchingValue: input.domain,
mappings: [
{ columnSlug: "research_brief", value: brief },
{ columnSlug: "rubric_version", value: RUBRIC_VERSION },
],
});
memory.set({
key: input.domain,
value: true,
expiresIn: { value: 30, unit: "day" },
});
return { researched: true };
},
);
What each line buys you on the next run:
memory.get/memory.setwith a 30-dayexpiresInis the cooldown. The default scope isworkflow, private to this workflow, so another play can research the same account for a different reason.set,getOrSet,incrementanddecrementare rejected without anexpiresIn, which is the point: bookkeeping that never expires turns into a block list nobody remembers creating.memory.incrementwithscope: "workspace"is an atomic counter shared by every workflow, so two plays running at once cannot both take the 200th slot. The key carries the date because every increment resets the expiry: a fixedbriefs-todaykey on a busy workspace would never expire, and once the cap was hit it would stay hit. A dated key starts at zero each day, and the two-day expiry only cleans up.model.upsertonto the account is the history. The brief lands on the same record the CRM sync, the scoring play and the rep’s view read, so the next run, and everything else, starts from it.rubric_versionon the record is how you answer “which rules produced this verdict?” six weeks later. BecauseRUBRIC_VERSIONsits next to the ICP change in the same pull request, the version on a record maps to a commit.
cargo-ai project plan shows the change and cargo-ai project deploy ships it. Every run then leaves a trace of each node, so a skipped account shows which branch skipped it.
Reading and correcting what the agent remembered #
Agent memory is the store teams forget to audit. On Cargo it is listable and editable from the CLI:
cargo-ai ai memory list --scope agent --agent-uuid <agent-uuid>
cargo-ai ai memory update --mem0-id <id> --content "<corrected fact>" --scope agent --agent-uuid <agent-uuid>
cargo-ai ai memory remove --mem0-id <id> --scope agent --agent-uuid <agent-uuid>
A useful weekly check: list the agent’s memories and move anything that reads like a rule (“we don’t sell to agencies”) into the context repository, then remove it from memory. Rules belong where a pull request can change them.
Decision rules #
- If another workflow or a person will ever ask the question, write it to the record. “When did we last research this account?” is a field, not a memory.
- If it should expire, use key-value memory with
expiresIn. Cooldowns, rate limits, “already notified this rep today”. - If changing it should need a review, put it in the repository. ICP, disqualifiers, playbooks, tone.
- Stamp the rule version on every verdict. Without it, a scoring change silently mixes old and new verdicts in the same pipeline report.
When this is more than you need #
A one-off research pass over a list does not need any of this: run the agent once and read the output. The plumbing earns its keep when the job runs again next week and someone owns the result, which is also when Cargo fits. If your team wants a spreadsheet interface and templates rather than code, this pattern is the wrong shape for you.
Frequently asked questions #
Write each run’s conclusions onto the account record (a brief, a score, the rule version that produced it) and have the next run read the record before it acts. History kept inside one agent’s memory is invisible to every other workflow and to the reps.
Look for three things rather than a “memory” checkbox: agents that read a shared account model, rules and playbooks stored as versioned files the agent reads at run time, and an expiring key-value store for cooldowns and caps. Cargo provides all three in one project. For a comparison of agent builders on other criteria, see best platforms to build AI agents for sales.
No. Memory an agent writes for itself is unreviewed and per agent. Keep the ICP in a repository every agent reads, change it through pull requests, and stamp its version on each verdict.
Sources #
Build this workflow instead of reading about it.
Cargo is the GTM infrastructure your coding agent builds on: enrichment, scoring, routing and outreach, defined in code and run in production.