Troubleshoot Agentforce DX Issues

When building agents with Agentforce DX, you can run into errors at any stage of the workflow. Stages include generating authoring bundles, coding Agent Script files, publishing to your org, running agent tests, and deploying metadata. This topic collects the most common issues and their solutions.

Environment Setup Issues 

Agentforce Isn't Enabled in Your Org 

Symptom: Some agent CLI commands fail with errors like This feature is not currently enabled for this user type or org or you can’t access Agentforce Builder in your org.

Solution:

  1. In your org, go to Setup > Einstein Setup and turn on Einstein.
  2. Go to Setup > Agentforce Agents and turn on Agentforce.

For scratch orgs, make sure that your scratch org definition file includes the Agentforce and Einstein features. For example:

1{
2  "orgName": "AFDX Pro-Code Testdrive",
3  "edition": "Developer",
4  "features": ["EnableSetPasswordInApi", "AgentforceStandardAgents"],
5  "settings": {
6    "agentPlatformSettings": {
7      "enableAgentPlatform": true
8    },
9    "einsteinGptSettings": {
10      "enableEinsteinGptPlatform": true
11    }
12  }
13}

See Set Up Your Development Environment for Agentforce DX.


Agent Script Errors 

The Agent Script .agent files are located in the aiAuthoringBundles/<api-name> directory of your DX project package directory, where <api-name> matches the API name of your agent’s authoring bundle.

Agent Script Validation Fails with a Syntax Error 

Symptom: Running agent validate authoring-bundle (or the equivalent VS Code AFDX: Validate This Agent command) returns a syntax error with a line number.

Solution: Open the .agent file and go to the reported line. Common syntax mistakes include:

  • Missing or extra indentation — Agent Script uses indentation to define block scope (similar to YAML), so misaligned lines cause parse errors
  • Missing colons after block or property names (for example, config instead of config:)
  • Referencing a variable that hasn’t been declared in the variables block
  • Using an unsupported expression type

The Agentforce DX VS Code extension includes support for the Agent Script Language, so you see inline error highlighting as you type in a .agent file in the VS Code editor.

See the Agent Script documentation.

Agent Preview Fails Immediately After Validation 

Symptom: Agent Script validation succeeds, but when you start a preview, the session fails to initialize.

Solution: Check that the access block in your .agent file includes a valid default_agent_user property set to an active agent user in your development org. This user is required for live mode and for Apex debug mode.

1access:
2    default_agent_user: "youruser@example.com.dev"

See Create the Default Agent User.

Authoring Bundle Issues 

The "agent generate authoring-bundle" Command Produces an Empty or Minimal Agent Script File 

Symptom: The generated .agent file has little content, just boilerplate blocks with no subagents.

Solution: Pass an agent spec file with the --spec flag. Without a spec, the command generates a default template. The spec file gives the LLM the context that it requires to generate meaningful subagent definitions.

1sf agent generate authoring-bundle --spec agent-specs/resort-manager.yaml

See Generate an Agent Spec File and Generate an Authoring Bundle.

Generated Agent Spec Contains Vague or Incomplete Details 

Symptom: After running agent generate authoring-bundle with a spec file, the generated Agent Script file doesn’t accurately reflect your use case, or the subagents are too generic.

Cause: The quality of the generated authoring bundle depends on how specific and complete your agent spec file is. The LLM uses your spec as the primary input.

Solution: Refine your agent spec file with accurate, complete, and specific details about your agent’s purpose, the topics it can handle, and the actions available. Include:

  • Clear descriptions of what the agent can accomplish
  • Specific business processes or workflows the agent supports
  • Detailed descriptions of available actions and when to use them
  • Example user requests or scenarios the agent can handle

Then regenerate the authoring bundle with the improved spec.

See Generate an Agent Spec File and Generate an Authoring Bundle.

Using "agent create" Instead of the Authoring Bundle Workflow 

Symptom: You used agent create to create an agent, but there’s no associated Agent Script file. Also, some of the Agentforce DX commands don’t work with it.

Cause: The agent create command creates an agent that doesn’t use Agent Script as its blueprint. This older workflow is no longer the recommended approach.

Solution: Use the authoring bundle workflow instead:

  1. Create an agent spec file describing your agent.
  2. Generate an authoring bundle with agent generate authoring-bundle --spec <spec-file>.
  3. Edit the generated .agent file.
  4. Publish with agent publish authoring-bundle.

See Build an Agent with Agentforce DX for the complete workflow.

Can't Package an Agent Template for an Agent Script Agent 

Symptom: You’re trying to package an agent template, but the command fails or doesn’t work for an agent created from an Agent Script file.

Cause: Agent template packaging currently doesn’t support agents that use Agent Script as their blueprint.

Solution: This issue is a known limitation. If you must package and distribute your agent, consider alternative distribution methods. Or check the latest Agentforce DX release notes for updates on this feature.


Publish Issues 

You publish an agent’s authoring bundle with either the agent publish authoring-bundle CLI command or the AFDX: Publish This Agent VS Code command.

Publish Succeeds but the Agent Doesn't Appear in Agentforce Builder 

Symptom: agent publish authoring-bundle completes without errors, but you can’t find the agent in your org.

Solution: Check these things:

  • Confirm you’re looking in the correct org. Run sf org display to verify your default org.
  • In Agentforce Builder, refresh the page. New agents aren’t always reflected immediately.

Apex or Flow Changes Aren't Reflected in Live Preview After Publish 

Symptom: You changed an Apex class or flow, published the authoring bundle, but the live preview still behaves as before.

Cause: Publishing an authoring bundle doesn’t deploy Apex classes or flows, which are separate metadata types.

Solution: Deploy your Apex and flow changes before publishing the authoring bundle.

1sf project deploy start --metadata "ApexClass:MyActionClass"
2sf agent publish authoring-bundle --api-name My_Agent

Sync and Retrieve Issues 

Retrieve Doesn't Return All Authoring Bundle Versions 

Symptom: After running project retrieve start --metadata AiAuthoringBundle:My_Agent, only one version appears in your DX project.

Solution: Use the wildcard syntax to retrieve all versions.

1sf project retrieve start --metadata "AiAuthoringBundle:My_Agent*"

Without the wildcard, the command retrieves only the unversioned (draft) bundle.

Deploy Fails with "missing required metadata" 

Symptom: project deploy start fails with an error about missing Bot or BotVersion components.

Cause: A committed agent requires both AiAuthoringBundle and Bot/BotVersion to deploy. If you’re deploying to a new org that doesn’t have the agent yet, you need both.

Solution: Use a manifest file that includes all the required metadata types. See Use Metadata to Move an Agent to a New Org and the manifest examples.


Preview and Debug Issues 

See Preview and Debug an Agent for details.

Unclear Whether to Use Simulated or Live Mode for Preview 

Symptom: You’re not sure whether to use --use-live-actions or --simulate-actions when starting a preview.

Solution: Choose based on what you’re testing:

  • Use --simulate-actions when your Apex classes, flows, or prompt templates aren’t yet available in your org, or when you want to test just the Agent Script logic without executing real actions.
  • Use --use-live-actions when you want to test the agent with actual Apex classes, flows, and prompt templates deployed to your development org. This mode is required to use the Apex Replay Debugger.
1# Simulated mode - mocks all actions
2sf agent preview --api-name My_Agent --simulate-actions
3
4# Live mode - uses deployed actions
5sf agent preview --api-name My_Agent --use-live-actions

In VS Code, use the AFDX: Preview this Agent command and select either Simulation or Live Test from the drop-down in the Agent Preview tab.

Apex Debugger Doesn't Work in Preview 

Symptom: You’ve set breakpoints in your Apex code, but they aren’t hit during agent preview.

Solution: The Apex Replay Debugger only works in live mode. Make sure you’re using --use-live-actions when starting your preview session, and verify that Apex debug mode is enabled in your VS Code settings.

Simulated mode mocks all actions, so no actual Apex code executes.

Multiple Preview Sessions Are Active for the Same Agent 

Symptom: When using programmatic agent preview, you see an error about multiple active sessions when you try to send a message to an agent.

Solution: If you have multiple preview sessions for the same agent, specify which session to use with the --session-id flag. List all active sessions first.

1# List active sessions
2sf agent preview sessions --api-name My_Agent
3
4# Send message to specific session
5sf agent preview send --api-name My_Agent --session-id <session-id> --utterance "Hello"

To avoid confusion, stop unused sessions with sf agent preview stop --session-id <session-id>.


Testing Issues 

"agent test create" Fails with "agent not found in org" 

Symptom: Running agent test create returns an error that the agent doesn’t exist.

Cause: You must publish the agent to your org before you can create a test against it.

Solution: Publish the authoring bundle first.

1sf agent publish authoring-bundle --api-name My_Agent --target-org my-dev-org
2sf agent test create --spec test-specs/resort-manager-tests.yaml --api-name My_Agent_Test

Tests Pass Locally but Fail in CI 

Symptom: Tests pass when you run them manually with agent test run, but fail in your CI pipeline.

Solution: Check these common CI-specific issues:

  • Org authentication: Make sure that your CI environment is authorized to your development org using a JWT-based auth flow. Web login isn’t available in CI. See Set Up Your Development Environment for JWT setup.
  • Agent not activated: Some tests require the agent to be activated. Add an agent activate step before running tests in your CI script.
  • Async timing: If you’re using asynchronous test runs without --wait, poll for results with agent test resume --job-id <id> before evaluating pass/fail status. Note that exit code 1 means test cases had execution errors, not that assertions failed. Check the result output to distinguish the two.
  • Agent activation: Some tests require the agent to be activated. Add an agent activate step before running tests in your CI script.

Test Results Show Low Metric Scores 

Symptom: The test runs but metrics like coherence score below your threshold.

Solution: Low metric scores usually point to agent instructions or action descriptions that are too vague. Try these approaches:

  • Refine the system instructions in your Agent Script’s start_agent block.
  • Add more descriptive action descriptions in the relevant subagent definitions.
  • Use agent preview to have a freeform conversation and examine the trace output to understand where the agent’s reasoning diverges from your expectations.

See Customize the Agent Test Spec and Preview and Debug an Agent.


See Also