sf agent preview can never start a session with a published Employee Agent:
Error - Bad Request: Invalid user ID provided on start session:
productionAgent.ts hardcodes bypassUser: true:
https://github.com/forcedotcom/agents/blob/597dad0fca74c81aa8fa3a89b1718aa65c6bfbde/src/agents/productionAgent.ts#L355-L362
Per the Agent API reference, true means "use the user associated with the agent" and is only for the client credentials flow; the default is false. Employee Agents have no agent user (BotDefinition.BotUserId is null by design), so the server resolves an empty user ID.
Same org, same agent, same JWT, varying only bypassUser:
| body |
result |
bypassUser: true (what the CLI sends) |
400 Invalid user ID provided on start session: |
bypassUser: false |
200, session created, messages exchanged |
userId (explicit) |
400 Unrecognized field "userId" |
The Agent Script path in the same package already handles this:
https://github.com/forcedotcom/agents/blob/597dad0fca74c81aa8fa3a89b1718aa65c6bfbde/src/agents/scriptAgent.ts#L481-L493
The production (published agent) path is missing the equivalent.
Repro: deploy and activate any Employee Agent (reproduced with coral-cloud), then sf agent preview --api-name <agent>. The agent is listed as (Published), so discovery works — only the session start fails.
Suggested fix: derive bypassUser in productionAgent.ts instead of hardcoding it, mirroring scriptAgent.ts.
Workaround: none from the CLI (no flag or env var). Calling the Agent API directly with bypassUser: false works.
Env: @salesforce/cli 2.143.6, @salesforce/plugin-agent 1.44.4, @salesforce/agents 1.10.2, Node 24.18.0, macOS arm64, Agentforce Developer Edition (API v67.0)
sf agent previewcan never start a session with a published Employee Agent:productionAgent.tshardcodesbypassUser: true:https://github.com/forcedotcom/agents/blob/597dad0fca74c81aa8fa3a89b1718aa65c6bfbde/src/agents/productionAgent.ts#L355-L362
Per the Agent API reference,
truemeans "use the user associated with the agent" and is only for the client credentials flow; the default isfalse. Employee Agents have no agent user (BotDefinition.BotUserIdis null by design), so the server resolves an empty user ID.Same org, same agent, same JWT, varying only
bypassUser:bypassUser: true(what the CLI sends)Invalid user ID provided on start session:bypassUser: falseuserId(explicit)Unrecognized field "userId"The Agent Script path in the same package already handles this:
https://github.com/forcedotcom/agents/blob/597dad0fca74c81aa8fa3a89b1718aa65c6bfbde/src/agents/scriptAgent.ts#L481-L493
The production (published agent) path is missing the equivalent.
Repro: deploy and activate any Employee Agent (reproduced with coral-cloud), then
sf agent preview --api-name <agent>. The agent is listed as(Published), so discovery works — only the session start fails.Suggested fix: derive
bypassUserinproductionAgent.tsinstead of hardcoding it, mirroringscriptAgent.ts.Workaround: none from the CLI (no flag or env var). Calling the Agent API directly with
bypassUser: falseworks.Env:
@salesforce/cli2.143.6,@salesforce/plugin-agent1.44.4,@salesforce/agents1.10.2, Node 24.18.0, macOS arm64, Agentforce Developer Edition (API v67.0)