Skip to content

agent preview start --authoring-bundle crashes for AgentforceEmployeeAgent without default_agent_user (reading 'replace') #3676

Open

Description

@joananwolfcobracrm

Summary

sf agent preview start --authoring-bundle <name> crashes for an Agent Script agent of type AgentforceEmployeeAgent that has no default_agent_user in its config block (employee agents run as the logged-in user, so this field is not set).

Steps to reproduce

  1. Agent Script authoring bundle with:
    config:
        developer_name: "My_Employee_Agent"
        agent_type: "AgentforceEmployeeAgent"
    
    (no default_agent_user)
  2. sf agent validate authoring-bundle --api-name My_Employee_Agent → success
  3. sf agent preview start --authoring-bundle My_Employee_Agent --use-live-actions --target-org <sandbox> --json

Expected result

A preview session starts (as it does for sf agent preview start --api-name My_Employee_Agent on the published, activated version — that works fine).

Actual result

PreviewStartFailed: Failed to start preview session: Cannot read properties of undefined (reading 'replace')
  cause: TypeError: Cannot read properties of undefined (reading 'replace')
      at ScriptAgent.startPreview (@salesforce/agents/lib/agents/scriptAgent.js:391:93)

Cause

@salesforce/agents/lib/agents/scriptAgent.js line 391:

const escapedDefaultAgentUser = this.agentJson.globalConfiguration.defaultAgentUser.replace(/'/g, "''");

defaultAgentUser is undefined for employee agents without default_agent_user. A guard such as (defaultAgentUser ?? '') — or skipping the user lookup when it is undefined, since bypassUser is forced to false for AgentforceEmployeeAgent a few lines later anyway — would fix it.

System information

  • @salesforce/cli/2.156.8 darwin-arm64 node-v24.22.1
  • @salesforce/plugin-agent 2.2.3, @salesforce/agents 2.3.1
  • Also reproduced on @salesforce/cli/2.154.4
  • Target org: sandbox, Agentforce employee agent

Activity

  1. added
    bugIssue or pull request that identifies or fixes a bug
    area:afdxCLI issue within plugin-agent or agents library
    on Oct 30, 2026
  2. git2gus commented on Oct 30, 2026

    @git2gus

    This issue has been linked to a new work item: W-24726042

  3. added
    owned by another teamThe Salesforce CLI team does not own this work but will pass on the information to the correct team.
    on Oct 30, 2026
  4. github-actions commented on Oct 30, 2026

    @github-actions

    We have determined that the issue you reported exists in code owned by another team that uses only the official support channels. To ensure that your issue is addressed, open an official Salesforce customer support ticket with a link to this issue. We encourage anyone experiencing this issue to do the same to increase the priority. We will keep this issue open for the community to collaborate on.

  5. WillieRuemmele commented on Oct 30, 2026

    @WillieRuemmele
    Member

    hi @joananwolfcobracrm - the team acknowledged this, and already has a fix on its way! Should be available next Wednesday, try nightly or latest-rc to confirm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:afdxCLI issue within plugin-agent or agents librarybugIssue or pull request that identifies or fixes a bugowned by another teamThe Salesforce CLI team does not own this work but will pass on the information to the correct team.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions