• SalesforceChaCha
  • Posts
  • ๐Ÿ’ƒ Where Should an Agent Actually Execute? ๐Ÿ•บ

๐Ÿ’ƒ Where Should an Agent Actually Execute? ๐Ÿ•บ

LOCATION, LOCATION, LOCATION

Good morning, Salesforce Nerds!

Your agent can run inside Salesforce.

That sentence ends too many architecture reviews. ๐ŸŽฏ

โ€œCanโ€ is a capability. โ€œShouldโ€ is a decision.

Architects get paid for the second one. ๐Ÿ’ฐ

Every enterprise now asks where the agentโ€™s reasoning and actions should live. Traditional application design never made you pick a home for software that thinks. ๐Ÿง 

Choose badly and you pay in security gaps, integration sprawl, latency, cost, and maintenance. Choose well and nobody notices, which is the architectโ€™s version of applause. ๐Ÿ‘

Not every problem needs an agent, either. A Flow that works is not a failure of imagination. ๐ŸŒŠ

This issue gives you a framework for the choice.

Five ideas, one argument: location is architecture.

TABLE OF CONTENTS

HOME FIELD VS. AWAY GAME

NATIVE OR EXTERNAL EXECUTION

Agentforce earns its place when the work lives in Salesforce. Records, flows, Apex actions, and sharing rules sit one hop away. ๐Ÿ 

Native execution gives you a short path to data and a security model you already govern.

The agent acts through a Salesforce user, so field-level security and sharing rules still apply. The Einstein Trust Layer adds masking so sensitive fields stay out of prompts. ๐Ÿ›ก๏ธ

Latency favors native too. No network hop separates the reasoning from the record it edits.

Then the meter starts. Flex Credits price an agent action at 20 credits, about 10 cents at list, so a chatty agent earns a budget line. ๐Ÿ’ธ

Default to native for Salesforce-centric work. Leave only when the job demands it, not when a demo dazzles.

External execution wins when the job spans systems.

Think ERP, ticketing, a data warehouse, and a model you picked yourself. A hyperscaler runtime or custom orchestrator hands you control over models, tooling, and observability. ๐Ÿงฐ

The price of that freedom is ownership of identity, retries, and uptime. Freedom has a pager. ๐Ÿ“Ÿ

DIVIDE AND DONโ€™T CONQUER

HYBRID WITHOUT THE HANGOVER

Most landscapes end up hybrid. The trick is dividing duties without welding systems together. ๐Ÿ”ง

Give each layer one job.

1๏ธโƒฃ Salesforce owns customer data and business process.

2๏ธโƒฃ Middleware owns routing and API governance.

3๏ธโƒฃ The external agent owns cross-system reasoning.

A practical split: Agentforce handles the customer conversation, an external agent reconciles inventory and pricing, and middleware brokers the calls. ๐Ÿงฉ 

Protocols loosen the weld. MCP gives an agent a standard way to call tools. A2A lets one agent delegate work to another agent that reasons on its own. ๐Ÿ”Œ

Salesforce supports both through Agentforce and MuleSoft, though some pieces have carried beta labels so besure to check release status before you commit a roadmap. ๐Ÿ“‹

Coupling hides in the details. If Agent A needs Agent Bโ€™s internal prompt format, you built a monolith with extra steps. ๐Ÿชข

Define handoffs by outcome and payload, never by internals. Then you can swap any layer without a rewrite.

WHO GETS TO SAY YES

IDENTITY AND AUTHORIZATION BOUNDARIES

Every action needs an answer to one question: whose permission is this? Answer it once, in one place. ๐Ÿ”‘

Inside Salesforce, the agent acts through a running user. That userโ€™s permissions set the blast radius, so scope it like a contractor, not an admin. ๐Ÿ”’

Outside Salesforce, the agent needs credentials for every system it touches.

Services such as AWS AgentCore Identity vault tokens and run OAuth flows on the agentโ€™s behalf. โ˜๏ธ

Decide which system owns authorization for each action. Authenticate at the edge and authorize where the data lives. ๐Ÿšช

Never hand an agent a humanโ€™s full session because it is convenient. Convenient is where audit findings come from. ๐Ÿ•ต๏ธ

Log every action with the agent identity and the human it served. Auditors ask, and shrugging is not a control.

PARTIAL SUCCESS IS FAILURE

TRANSACTIONS DONโ€™T SPAN SYSTEMS

Salesforce gives you a transaction. Your ERP gives you a different one. Nothing gives you both. โš–๏ธ

An agent that updates an Opportunity, calls billing, and then times out has created a crime scene.

Plan for it. ๐Ÿšจ

Ask one question for every step: what happens if this one fails after the last one succeeded?

Long-running work belongs off the synchronous path. Queue it, track its state, and let the agent check back. โณ

Retries demand idempotency. Send the same request twice and the downstream system must do the work once. ๐Ÿ”

// Conceptual: stable idempotency key, bounded retries, human escalation
public class BillingSyncJob implements Queueable, Database.AllowsCallouts {
    public void execute(QueueableContext ctx) {
        String key = 'opp-' + oppId + '-v' + version; // same key on every retry
        HttpResponse res = BillingClient.post(payload, key);
        if (res.getStatusCode() >= 500 && attempt < MAX_ATTEMPTS) {
            System.enqueueJob(new BillingSyncJob(oppId, version, attempt + 1));
        } else if (res.getStatusCode() >= 400) {
            ErrorLog.record(oppId, res); // park it for a human
        }
    }
}

Think in sagas: a chain of steps where each step has an undo.

Failure needs a plan. Compensate, park the work, or escalate to a human. Pretending failure cannot happen is not on the menu. ๐Ÿงฏ

PRINCIPLES BEFORE PLATFORMS

PLACE AGENTS ON PURPOSE

Pick principles, not a platform. Platforms change quarterly. Principles survive. ๐Ÿ“

Write down where agents may run, which systems they may touch, and who authorizes each action.

Add how work hands off across boundaries. ๐Ÿ“

Run natively when the work is Salesforce work. Run elsewhere when it is not. Run nothing when a rule will do. ๐ŸŽ›๏ธ

The Salesforce architect belongs at this table, fluent in the platform and the ecosystem around it. The seat goes to whoever brings the framework. ๐Ÿช‘

Executives get the same benefit: fewer surprises on the invoice and in the audit.

Where an agent runs is a decision, not a default. Make it on purpose. ๐Ÿงญ

SOUL FOOD

Todayโ€™s Principle

"Simplicity is prerequisite for reliability."

Peter Drucker

and now....Salesforce Memes

What did you think about today's newsletter?

Login or Subscribe to participate in polls.