Back to LinkedIn posts

LinkedIn post 30

Think once, store and refresh

Think once, store and refresh

When AI work is repetitive, do not call the model every time. Call it once to generate a script, then run the script.

Last week I tested this on Agentforce Vibes (AFV, Salesforce's coding agent). The task was: for each object in the Salesforce project folder, check that fields referenced in active validation rules also appear on the page layouts tied to each record type.

That operation required execution of these steps for each object:
- get a list of active validation rules
- parse out the fields from each rule
- get a list of page layouts associated with the given record type
- cross-check and determine whether the field mentioned in the validation rule is on the page layout

AFV's default approach was to walk the steps itself, object by object, burning tokens on work that a deterministic script can do once. I asked it to write the script instead.

It produced a Node.js version that mostly worked, but silently returned no layouts for Task and Event. The agent was pulling from the wrong folder for those two objects.

The fix was to have the agent write intermediate artifacts to disk so you can inspect the chain. In this case the page-layout list came back partly empty, which made the bug obvious.

Paul Levy 's article linked below describes a similar pattern:
🔗 https://www.linkedin.com/pulse/beautiful-constraint-aws-llms-paul-levy-mqisc/

The pattern "think once, store and refresh": instead of calling the AI every time, call it once and store the result (in my case, a script), then use the script instead of AI.

Another similar pattern is also known in software engineering as memoization.

When LLM pricing stops being subsidized, the teams that already work this way will not feel the squeeze as badly.

graphical user interface, text