Design hybrid reasoning with Agent Script
Decide which steps require deterministic execution and which can use model reasoning.
Design hybrid reasoning with Agent Script
Work through the decision
A dealer asks whether a damaged bicycle qualifies for a replacement. The conversation can vary, but eligibility must be verified before an action may place an order. How should the agent divide the work?
Check your reasoning
Use a subagent with a defined scope, instructions and authorized actions. Use natural-language reasoning to interpret the problem and ask for missing details. Express mandatory prerequisites and transitions as deterministic logic. Store the verified state in a variable and check it before exposing the action. Validate the same business invariant inside the underlying operation.
Compare the choices
- Subagent scope
- Define a bounded job and the circumstances under which the agent should route a request to it. Scope separates warranty service from unrelated sales work.
- Natural-language instructions
- Guide reasoning about variable input, clarification and language. Use precise boundaries and examples for the assigned job.
- Deterministic logic
- Use explicit conditions, ordered steps and transitions for mandatory checks. Verify critical invariants in the action as well.
- State variable
- Store typed state such as a verified dealer ID or approval result for use by later logic. Keep trusted facts separate from unverified user text.
- Agent action
- Expose a defined capability with documented inputs, outputs and side effects, such as a Flow to check a claim. Grant only the access needed for the operation.
- Canvas and Script views
- Use the visual and textual views to edit and inspect the same Agent Script definition. Recheck the resolved behavior after changes in either view.
Test the decision
Open Canvas to review the flow of the conversation with a domain expert and Script View to inspect exact conditions. Both edit the same agent definition. In preview, send a clear request, an ambiguous request and an ineligible request. Trace which branch resolves and which instructions and actions become available.
Trace a branch in the builder
The guide uses both topics and subagents. Salesforce renamed topics to subagents in April 2026. Start a test with an unset approval flag, then supply a trusted approval result. Compare the selected subagent, available actions and transition in both runs. Inspect the same definition in Canvas and Script View and record which decisions the script settles before model reasoning.
Salesforce Developers · Agent Script
Practice the guide skills
- Sketch one Agent Script subagent with a bounded scope, instructions, action inputs, state variables and a transition for a missing claim number. Trace one complete conversation. Watch 54:32
- Mark each step as deterministic logic or a reasoning decision. Inspect the same branch in Canvas and Script View and verify how the selected branch changes the model’s available context. Watch 1:03:05
Official objectives for this lesson
Related lesson · Build and publish a grounded service agent
Design hybrid reasoning with Agent Script quiz
Answer 3 questions. Check each answer for an explanation.