Agentforce Gotcha: Why Your Second Agent Still Runs as the First User

🌐 The Real-World Scenario

Let’s take a simple setup:

  • Agent-1 → placed on a Community Page.
  • Agent-1 triggers a Flow action to insert a record.
  • That Flow then calls Agent-2, which sends a notification to an external system.

Now, here’s the twist 🌀:
Even if you configure different users for each agent, you’ll find that Agent-2 still runs using Agent-1’s user context.


🔍 Why This Happens

This behavior comes down to how Agentforce handles execution:

  • When an agent is invoked from Flow or Apex, it inherits the running user’s context at the time of invocation.
  • If the same sessionId is carried forward, the second agent is treated as a continuation of the first agent’s conversation.
  • While Flows can run in system or user context, the actual running user still defines identity for anything executed inside — including calls to external systems (like Slack via External Credentials).

Result: Agent-2 doesn’t switch to its own configured user. Instead, it continues with Agent-1’s user context.


🧭 Key Takeaway

Agentforce agents, when chained together, will always “inherit” the invoking user unless a brand-new session is created. This means:

  • If Agent-1 calls Agent-2, the second agent executes as if it’s still Agent-1.
  • Even with different user assignments, the context flows downstream, not independently.

👉 Understanding this subtle detail is critical when designing multi-agent automations so you know exactly whose “identity” is in play.


✨ That’s one of those hidden gems in Agentforce design that can surprise many builders at first glance!