A governed Agent Network 2.0 for a consumer brand: Salesforce Agentforce Shopper and Service agents reach reviews, delivery tracking, returns, promotions, payments, consent, CDP and CMS systems outside Salesforce through five A2A brokers and MCP servers on MuleSoft Agent Fabric. Covers the broker design, the single-call tool pattern that keeps agents inside the runtime's reasoning limit, API Manager governance, a test-double MCP app for lower environments, and the deploy traps that ship stale brokers.
Tags: agentforce, agent-fabric, agent-network, a2a, mcp, agent-script, retail, consumer-goods, order-management, loyalty, payments, anypoint-platform, api-manager, governance
Agentic Commerce: Agentforce Shopper and Service Agents on MuleSoft Agent Fabric v2
Deliverable: A deployed Agent Network 2.0 with five A2A brokers and 17 MCP connections that lets Agentforce Shopper and Service agents answer reviews, delivery, returns, loyalty, refund, consent, personalization and content questions from systems that are not in Salesforce, under API Manager governance, with a test-double MCP app for every lower environment.
Objective: A consumer brand's Shopper and Service agents are strong on what Salesforce holds (catalog, orders, cases) and stall on everything else: restock dates live in the fulfillment system, refund state in the payment processor, points in the promotions engine, reviews in the ratings platform, consent in the privacy platform. Those answers used to arrive as nightly flat files, so the agent says "please check the website." This blueprint puts one governed front door in front of those systems: agents keep their channel, brokers own the cross-system lookups, and every outside call has an identity, a rate limit and an audit trail.
What's Getting Built
- shopper_service_router_broker (front-door broker) — classifies each request as SHOPPING or SERVICE and delegates over A2A to the Shopper or Service agent; lookup context from a Salesforce SObject MCP and an Orders API MCP ·
POST {ingress}/shopper_service_router_broker/ (A2A SendMessage)
- perfect_order_broker (service broker) — order status, carrier tracking, return initiation, split/expedite/restock · tools
get-order-status (OMS), get-carrier-status (carrier), process-return (returns platform, e.g. Narvar), get-fulfillment-options (fulfillment system)
- product_intelligence_broker (shopper broker) — ratings, review volume, trend, and two-product comparison · tool
get-product-reviews (reviews platform, e.g. BazaarVoice)
- product_discoverability_broker (shopper broker) — search, related gear, buying guide, care, store stock, promotion · tool
search-products (search index) returning the folded payload described in step 4
- loyalty_payments_broker (service broker, every system outside Salesforce) — tier and points, promo eligibility, refund and BNPL status, privacy requests · tools
get-loyalty-status, check-promo-eligibility (e.g. Talon.One), get-payment-status (e.g. Adyen), submit-privacy-request (e.g. OneTrust)
- Agent registrations —
shopperAgent, serviceAgent, discoveryAgent, each an Agentforce agent with an A2A 1.0 JSON-RPC card
- Governance layer (API Manager) — identity, rate limits, PII scrub, hallucination limit, telemetry, human-in-the-loop on returns
- Test-double MCP app (Mule 4, lower environments only) — one streamable-HTTP MCP server per system at
/mock/{system}/mcp
Prerequisites
- Anypoint org with Agent Fabric (Agent Network 2.0), CloudHub 2.0 private space, API Manager, Exchange publish rights, and the Anypoint CLI v4 Agent Fabric plugin at its current version (an asset built by an older plugin crashes the 2.0 runtime on start).
- Agentforce Shopper and Service agents reachable over A2A 1.0 (JSON-RPC), with a card URL each.
- An LLM endpoint, ideally an API Manager LLM proxy,
{llm_gateway}, that holds the provider key and AI policies; brokers authenticate with a key supplied at deploy time.
- A real MCP endpoint per external system. This is the long pole: vendor sandbox access, read-only service accounts, and privacy sign-off outlast the network build.
- Written decisions on which broker may call which system, the return-value threshold for human approval, and which review text may leave your boundary.
Choose your path
- Brokers (this blueprint) — when answers live in three or more non-Salesforce systems and you need per-agent identity, rate limits, and one audit trail.
- Direct Agentforce actions to a System API — when one or two systems cover the use cases; a broker adds a hop and an LLM loop you do not need.
Architecture
1. Draw the Salesforce boundary and assign every system to one broker
- List every system each use case needs and mark it inside or outside Salesforce. In the proven map, 9 of 13 systems were outside: reviews, fulfillment, returns, loyalty, payments, CDP, CMS, consent, store inventory. Outside systems are the broker's job; inside ones stay with the agent.
- Assign each outside system to exactly one broker by domain (see What's Getting Built). One owner per system keeps policy attachment and incident ownership unambiguous.
- This prevents a mega-broker with a dozen tools, the shape that exceeds the runtime's reasoning limit (step 4).
2. Describe the network once in the descriptor
- In
agent-network.yaml (agentNetwork: 2.0.0) declare under registry the agents (A2A card with protocolBinding: JSONRPC, protocolVersion: "1.0", skills), the MCPs (transport.kind: streamableHttp, path: /mcp) and the LLM. Under context.connections bind each by kind: a2a | mcp | llm with a ${name.url} variable. Under brokers point each at its .agent file with a card URL of ${ingressgw.url}/{broker}.
- Every URL and the LLM key are deploy-time variables (
authentication.kind: apiKey, ${llmProxy.apiKey}); nothing secret is in the repo.
- The model that runs is the one in the registry's LLM entry; the
model: line in each .agent file is cosmetic.
- Keep card
skills: in sync with actions:. Skills only advertise; actions create the MCP clients ({action_name}-client).
3. Write each broker as one bounded orchestrator
- Each
.agent file (dialect AGENTFABRIC=1.2, the version used by the v1 to v2 migration blueprint; use the one your CLI plugin generates) has a trigger on brokers://{broker}/a2a, one orchestrator with a short fixed plan, and an echo that returns TASK_STATE_COMPLETED with the summary as a text part. actions: bind mcp://{connection} with kind: "mcp:tool" and tool_name.
- Write instructions as an imperative plan with a stop condition. For
perfect_order_broker: always call get_order_status once; if found=false, stop and say the order was not found; otherwise make exactly one more call by intent (delivery to carrier, return to returns platform, split/restock/expedite to fulfillment); never more than two calls, never the same tool twice.
- Ground every sentence: base statements strictly on tool responses; never invent point balances, refund states or promotion rules.
- Do not rely on
executor, router when: or set @variables for correctness. In the runtime version this was built on, they compiled and deployed but did not execute (recheck after each plugin or runtime upgrade): a not-found order produced five different invented shipping answers in five calls. The router broker's generator to router intent split is the one graph node used, so treat it as advisory (see Deterministic checks).
4. Fold each domain into one rich tool response
- The runtime enforces a hard, non-configurable, model-independent reasoning-iteration limit. The reliable remedy is structural: one or two tools per broker, and tool responses that already hold everything the question needs.
search-products returns results plus buyingGuide, careInstructions, relatedGear, storeAvailability and promotion, with responseIsComplete: true and an answeredFacets list. get-product-reviews takes one or two product names and returns both profiles plus a verdict. get-fulfillment-options returns shipments[] with per-box status, restock date and new ETA.
- Build those payloads in the MCP service, not the prompt. If a scenario flakes, enrich the one response and tighten the stop rule; do not add a second tool. Occasional limit failures remain, so treat them as retryable and never show a truncated answer.
5. Wrap each vendor as an MCP service
- A Mule 4 app using the MCP connector:
mcp:server-config on an HTTP listener, one mcp:tool-listener per tool with a JSON-Schema parameters-schema and a text response. Keep inputs minimal (orderId, customerId, sku).
- Return
found: false with status: null for unknown ids, never a plausible default; it is the only dependable not-found signal.
- Return only fields the answer needs (refund state, last four digits). Escape every literal
$ in DataWeave strings (\$) and validate scripts offline; a bad script builds clean and fails at runtime.
6. Test double for lower environments
- One Mule app serves all 17 MCP servers and 3 A2A agent cards from fixed DataWeave payloads at
/mock/{system}/mcp, so brokers, instructions and governance can be regression-tested before vendor sandboxes exist. It is a test double, not an integration: label it as such, run it only in non-production, and swap in the real MCP service (same tool names and schemas) per system, keeping the double for CI.
- Keep it contract-faithful: any field a broker prompt relies on (
found, responseIsComplete, restockDate) must also come from the real service.
7. Govern the reach in API Manager
- Apply policies to broker and connection endpoints, not inside
.agent files:
- Trusted identity per agent: the Service agent may call
perfect_order_broker and loyalty_payments_broker; the Shopper agent may not.
- Rate limiting per agent group: external channels such as general-purpose chat assistants get a read-only subset and lower limits.
- PII scrub and hallucination limit on review text in
product_intelligence_broker.
- A2A telemetry on every agent-to-agent hop, and human-in-the-loop for returns above the agreed value threshold.
- Consent: privacy and data-subject requests go only through the consent platform's MCP service.
8. Build, publish, deploy, and verify the version that runs
- Sequence:
agent-network project build, project publish, project deploy. Deploy packages a cached local build and resolves brokers from the published Exchange version, so an edited .agent file reaches runtime only after a clean rebuild and a publish.
- Confirm the broker version in the deploy log equals the one you just built; an older number means a stale broker is shipping.
- Supply every deploy variable (each connection URL,
ingressgw.url, llmProxy.url, llmProxy.apiKey); a missing one blocks the CLI on stdin until timeout. Take the key from a secret store.
- Deploy is idempotent. On 429 or 502, wait for the rate-limit reset and retry once. A client timeout does not roll back a server deploy in progress, so check status first.
9. Security and compliance
- Data protection: PCI scope stays with the payment processor; brokers see refund state and last four digits only. Consent decisions are made in the consent platform, never inferred by the agent. CDP data is used only for the identified customer in session.
- Transport and secrets: TLS on ingress and every MCP connection; keys in Secrets Manager or deploy-time secure variables.
- Audit: log task id, context id, broker, tool, outcome and latency per hop. Never log message text with names, emails or card data, or whole tool payloads.
- Write paths:
process-return and submit-privacy-request change state. Gate them with the human-in-the-loop policy and idempotency on {order_id} or {request_id}.
Sample payload — A2A 1.0 request to a broker, then the OMS tool result it grounds on
Request (POST {ingress}/perfect_order_broker/, trailing slash required; headers A2A-Version: 1.0, Content-Type: application/json):
{
"jsonrpc": "2.0",
"id": "req-001",
"method": "SendMessage",
"params": {
"message": {
"role": "ROLE_USER",
"messageId": "msg-001",
"parts": [{ "text": "Where is order {order_id}, and when does the backordered item restock?" }]
}
}
}
Response: state at result.task.status.state, answer text in result.task.status.message.parts[].text, audit keys result.task.id and contextId. The tool result the broker grounds on (placeholder values):
{
"orderId": "{order_id}",
"status": "shipped",
"found": true,
"shippedDate": "{yyyy-mm-dd}",
"carrier": "{carrier}",
"trackingNumber": "{tracking_number}",
"eta": "{yyyy-mm-dd}",
"lineItems": [{ "sku": "{sku}", "name": "{product}", "quantity": 1, "status": "shipped" }]
}
Not-found variant: { "orderId": "{order_id}", "status": null, "found": false }.
Deterministic checks
- Protocol: a pre-1.0 request (
message/send, role user) is rejected; the 1.0 shape returns HTTP 200 with TASK_STATE_COMPLETED or TASK_STATE_INPUT_REQUIRED (a valid clarification). Address by broker instance id.
- Tool contract: each MCP service returns schema-valid JSON for known ids and
found: false with status: null for unknown ones. The same contract suite runs against the test double and the real service.
- Fail closed:
found: false yields the not-found reply with no second tool call. The graph does not enforce this, so test it: across repeated not-found calls, no carrier, date or status appears that is absent from tool output. TASK_STATE_FAILED, an unparseable router intent, or an answer without tool evidence becomes a human handoff, never a customer-facing answer. The router sends anything that is not exactly SHOPPING to the service path.
- Policy: a Shopper-agent token calling
loyalty_payments_broker gets 403; over-limit calls get 429; both are logged with agent identity.
- Idempotency: replaying a return or privacy request with the same
{order_id} or {request_id} creates no second vendor record.
- Tool budget: traces show at most two tool calls per task, none repeated.
Testing and validation
- Run at least 15 prompts across all five brokers through the real ingress (order status, split shipment, return, restock, comparison, store stock, tier and points, promo not applied, refund, privacy request, multi-intent), recording state, latency and tool trace.
- Edge case 1: a multi-intent request ("return these and show me something similar"). The router handles the service part first without dropping the shopping part; accept
TASK_STATE_INPUT_REQUIRED when the broker offers to continue.
- Edge case 2: an unknown order id, which otherwise yields a fluent, invented delivery story.
- Track
reasoning_iterations failures separately; a broker persistently over the limit needs more folded data, not more tools.
- Every number in a reply must trace to a field in the tool response.
Phased rollout
Phase 1 — Connect
- Deploy to a sandbox against the test double; prove A2A calls from the agents, LLM auth through
{llm_gateway}, and the version check.
Phase 2 — Map and validate
- Swap test-double routes for real MCP services one system at a time, keeping tool names and schemas. Attach policies, run the full harness, and agree the return threshold and PII rules with privacy owners.
Phase 3 — Production
- Start with read-only tools on internal channels, then enable
process-return and submit-privacy-request behind human approval. Add external channels, on the lower rate-limit group, last.
Success metrics
- Share of in-scope contacts resolved without escalation, by broker; order-status (WISMO) and refund-status contacts reaching human agents.
- Per-broker task success rate,
reasoning_iterations failure rate, p95 latency, tool calls per task.
- Policy outcomes: blocked calls, rate-limited calls, PII scrubs, returns routed to approval.
- Contract-test pass rate between the test double and real MCP services.
Troubleshooting
- Broker crash-loops on a removed tool (
MCP client '{action}-client': connection URL could not be resolved) after a fix — Likely cause: deploy shipped a cached build or older published version. Fix: clean rebuild, publish, redeploy, check the logged version.
TASK_STATE_FAILED, "system limit was exceeded: reasoning_iterations" — Likely cause: too many reasoning steps; not configurable. Fix: retry once, fold more data into the single tool response, tighten the stop rule, drop extra tools.
- 404 or immediate rejection — Likely cause: card display name or missing trailing slash, or a pre-1.0 message shape or missing
A2A-Version: 1.0 header. Fix: use the instance id path with a trailing slash and the SendMessage shape.
- Deploy hangs, then command timeout — Likely cause: an unsupplied variable, or the client watch expired mid-deploy. Fix: supply all variables; check status before retrying.
- Tool returns the DataWeave script text in an error — Likely cause: unescaped
$ or bad construct that the build misses. Fix: validate scripts offline.
- Agent invents an answer for an unknown order — Likely cause: reliance on graph nodes that do not execute. Fix:
found: false, stop rule in instructions, repeated-call test.