Guided determinism for agents using AgentScript
Combining LLM flexibility with deterministic gates in Agentforce. Built around one real refund agent.
14 lessons73 min read
The pattern this tutorial teaches has a name in the research literature: it is a neuro-symbolic agent architecture, where a neural decision-maker (the LLM planner) operates inside a symbolic scaffold (typed variables, finite-state topic graph, available when gates). Lesson 12 traces this lineage in depth; see Where this fits in AI research for the full mapping to Kautz's taxonomy, ReAct-style tool use, constrained generation, and the CoALA framing.
The soft neural choice sits inside hard symbolic gates. More on the research lineage →
Lessons
- 1.The scenario6 min
Read this first. Every snippet, diagram, and bug in the tutorial comes from this one refund agent.
- 2.Why this is hard4 min
Pure-prompt agents stall. Pure-deterministic agents are brittle. Guided determinism is the middle path.
- 3.The mental model: four control surfaces5 min
Topic boundaries, instructions, available-when gates, and after_reasoning. Knowing which to reach for first is the whole skill.
- 4.Anatomy of a turn5 min
What actually happens between user input and assistant reply. Enabled tools are computed before the LLM sees anything.
- 5.Invocable Apex: writing actions worth trusting6 min
Bulk shape, reserved names, truthful nulls, deterministic outputs. Stubs that lie poison the planner.
- 6.The toolchain and the dev loop5 min
Edit, validate, deploy, preview, trace, fix, publish, activate. Don't publish during inner-loop iteration.
- 7.Reading session traces6 min
Traces are the truth. EnabledToolsStep tells you what the LLM saw; VariableUpdateStep tells you why state changed.
- 8.Bug 1: the silent permission filter6 min
The agent runs as the Einstein Agent User, not you. Apex without permset access disappears from enabled_tools with no error.
- 9.Bug 2: the planner that lies7 min
@outputs.X is what the planner says Apex returned. Vague schemas plus sticky context produce convincing fabrications.
- 10.Defense in depth5 min
Schema descriptions, flag-based gates, server nonces, re-fetch on next action. Layer 2-3 anywhere stakes are real.
- 11.The free-roam variant: when to relax4 min
Same Apex and same gates, prompt-only orchestration. Safe because the deterministic surfaces stay intact.
- 12.Where this fits in AI research9 min
Neuro-symbolic Type-2 hybrid. ReAct + constrained generation. Not model-based RL, not Soar.
- 13.Glossary3 min
Every term-of-art used across the tutorial, with one-line definitions.
- 14.Sticky-note appendix2 min
The seven things we wish we had known on day one.