Sub topic 10
Improving actions and action descriptions
This chapter assumes you can open a conversation and its reasoning steps, and that you have already classified a failure as an action problem. It also assumes you have built an agent with at least one Flow or Apex action in Agentforce Builder. The goal is to turn a diagnosed action failure into a specific change that you can test and release.
What an action problem looks like
An action is a capability the agent can call, such as a Flow, an Apex method, a prompt template, or an API call. The model never sees the code. It sees the action's name, its description, and the names and descriptions of its inputs and outputs. It uses that text to decide whether to call the action and what values to pass.
A reasoning trace usually shows an action problem in one of four ways:
- Wrong action chosen. The topic was right, but the agent called a similar action instead.
- Action not called. The agent answered from its own wording or from knowledge when it should have looked something up.
- Bad inputs. The action ran with a guessed, empty, or wrongly formatted value.
- Output mishandled. The action returned correct data and the agent ignored it, misread it, or exposed a field the customer should not see.
If the trace shows the wrong topic was chosen, fix the topic first. Tuning actions inside the wrong topic changes nothing.
Count failures by action
Single conversations show you a symptom. A count across many conversations shows you which action to fix first. If you can export reviewed action calls, group them by the action that was chosen. The field names below are illustrative, not an Agentforce schema.
from collections import defaultdict
# Hypothetical export of reviewed action calls.
# "expected" is the action a reviewer says should have been used.
calls = [
{"id": "c1", "chosen": "Get Order Status", "expected": "Get Order Status", "error": None},
{"id": "c2", "chosen": "Get Order Status", "expected": "Start Return", "error": None},
{"id": "c3", "chosen": "Get Order Status", "expected": "Get Order Status",
"error": "MISSING_INPUT: orderNumber"},
{"id": "c4", "chosen": "Start Return", "expected": "Start Return", "error": None},
]
stats = defaultdict(lambda: {"calls": 0, "wrong": 0, "errors": 0})
for c in calls:
s = stats[c["chosen"]]
s["calls"] += 1
s["wrong"] += c["chosen"] != c["expected"]
s["errors"] += c["error"] is not None
for name, s in sorted(stats.items()):
print(f"{name}: calls={s['calls']} wrong={s['wrong']} errors={s['errors']}")Here Get Order Status accounts for both the wrong selection and the input error. That is where you start. The two failures have different fixes, so keep them separate in your notes.
Fix a wrong or missing action: the action description
The action description is the main signal for selection. Weak descriptions fail in predictable ways:
- They restate the name ("Gets order").
- They describe how the action works ("Runs the OrderLookup Flow") instead of when to use it.
- They overlap with a neighboring action and give no way to tell them apart.
A useful description states what the action does, what the customer must have asked for, and what it does not do.
BEFORE (action description)
Gets order information.
AFTER (action description)
Looks up the current status, tracking number, and estimated delivery date
of one existing order, using its order number. Use when the customer asks
where an order is or when it will arrive. Does not start returns, refunds,
or cancellations.Follow these rules when you rewrite:
- Lead with the customer's intent, not the implementation.
- Name the required identifier, such as the order number.
- State the exclusion for the nearest similar action, and write the matching exclusion in that action's description.
- Keep one purpose per action. If a description needs "and also", consider splitting the action.
- Use the customer's vocabulary. If customers say "tracking", include "tracking".
Action names matter too. Two actions named Get Order and Get Order Details invite confusion. Rename them so the difference is visible, for example Get Order Status and Get Order Line Items.
Fix bad inputs: input descriptions and collection
When the agent guesses an input, the cause is usually a vague input description or a missing instruction about when to ask.
- Describe each input with its meaning, format, and an example. "Order number. Digits only, for example 100245. Do not include a leading #."
- Mark inputs that the action cannot run without as required, if your Builder version offers that setting. The agent should then ask the customer instead of inventing a value. The exact labels and settings vary by release, so check your version.
- Add an instruction to the topic that says when to ask: "Ask for the order number if the customer has not given one."
- Do not let the model derive values that the system should supply. Pass the customer's identity from the session context or a variable instead of asking the model to remember it.
Normalize inputs in the Flow or Apex as well. If the agent passes #100245 and your lookup expects 100245, strip the # in the Flow. Relying only on a description is fragile, because the model follows it most of the time but not every time.
Fix action errors: the Flow or Apex
If the trace shows the action ran and returned an error, the fix is not in the description. Check:
- Fault paths. A Flow with no fault path returns a generic failure that the agent cannot explain. Add a fault path that returns a short, plain message.
- Empty results. "No order found" is a normal outcome, not an error. Return it as a clear result so the instruction can say what to do next, such as offering a human agent.
- Permissions. An action runs with specific access. A lookup that works for you in a test may return nothing for the agent's running user.
- Timeouts and callouts. Slow external calls produce intermittent failures that look like random agent behavior. Look for patterns by time of day.
Fix output handling
The agent reads the action's outputs and writes a reply from them. Problems here are often caused by returning too much.
- Return only the fields the agent needs. Extra fields give the model more chances to quote something wrong.
- Give outputs descriptive names and descriptions, so
estDeliveryis described as "Estimated delivery date, not guaranteed". - Hide outputs that must not appear in the reply, using the output visibility setting in Builder if your version has one. Hiding an output in the reply does not remove it from the conversation record, so apply the access rules from the privacy chapter.
- Use the topic instruction to describe what to do with each outcome: found, not found, and error.
Change one thing at a time
Make a single change per diagnosed failure, then retest. If you rewrite two descriptions and add an instruction together, you cannot tell which change helped, and one may have caused a new regression. Keep a short change log that names the failure, the change, and the test case that covers it.
After each change, turn the failed conversation into a regression test. Use the same format as the topic-level test: utterance, expected topic, expected action, and expected response behavior.
Test case: Delivery question calls the order status action
User utterance: Where is my package? Order 100245.
Expected topic: Order Status
Expected action: Get Order Status, with orderNumber = 100245
Expected response: Gives status and estimated delivery date from the action output, does not offer a return.Also add a negative case for the exclusion you wrote: a returns request must not call Get Order Status. Without the negative case, a later edit to either description can quietly bring the confusion back.
Common mistakes
| Mistake | Effect | Better approach |
|---|---|---|
| Describing the implementation | Model cannot tell when to use the action | Describe the customer intent |
| Overlapping descriptions | Wrong action chosen | Add exclusions to both actions |
| Optional inputs that are really required | Guessed values | Mark required and instruct the agent to ask |
| Returning every field | Wrong or sensitive details in replies | Return only needed outputs |
| Fixing the description for an Apex bug | No improvement | Check the action error first |
| Testing only the happy path | Regressions go unnoticed | Add negative and empty-result cases |
Exercise
Reviewers find that 12 of 40 returns conversations called Get Order Status, and the trace shows the topic was correctly set to Returns. Which part do you change first, and what do you add to the test set?
Show answer
Change the action descriptions, not the topic. Add an exclusion to Get Order Status ("Does not start returns, refunds, or cancellations") and make Start Return describe its own intent clearly, so the two no longer overlap. Add a test with a returns utterance that expects Start Return and not Get Order Status, and keep a positive order-status test to confirm the original behavior still works.
Exercise
The agent passes "#100245" to a lookup Flow that expects "100245", and the lookup returns nothing. Name two changes that would fix this, and say which one is more reliable.
Show answer
First, update the input description to say digits only with an example and no leading #. Second, normalize the value inside the Flow by removing the #. The Flow change is more reliable because it works even when the model ignores the description.