Skip to content

feat: service agent recipe with dx pipeline#93

Open
msrivastav13 wants to merge 14 commits into
mainfrom
feat/service-agent-recipe-with-dx-pipeline
Open

feat: service agent recipe with dx pipeline#93
msrivastav13 wants to merge 14 commits into
mainfrom
feat/service-agent-recipe-with-dx-pipeline

Conversation

@msrivastav13
Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a complete Agentforce Service Agent recipe (CustomerServiceAgent) with a full developer experience pipeline for agent user management. Service Agents differ from Employee Agents by running under a dedicated agent user rather than the logged-in user — this PR demonstrates that pattern end-to-end with deploy-time placeholder replacement and pre-commit cleanup.

Key changes:

  • New recipe: force-app-service/customerServiceAgent/ — a service agent that classifies issues,
    searches a knowledge base, and creates or escalates cases using subagent transitions, Apex
    (IssueClassifier), and Flows
  • DX pipeline: scripts/setup-service-agent.js creates the agent user and replaces
    AGENT_USER_PLACEHOLDER in .agent files; scripts/clean-service-agent.js restores it before
    commits via a pre-commit hook
  • Dedicated permission set: Customer_Service_Agent_Data lives inside force-app-service to avoid
    cross-directory deploy failures with the shared permission set
  • CI/CD updates: Both ci.yml and ci-pr.yml deploy the service agent, assign permission sets to
    the agent user using GITHUB_OUTPUT step outputs (no brittle file grep)
  • Script reorganization: Node scripts moved from bin/ to scripts/; setup-service-agent.js
    outputs the username to stdout for clean shell capture

What issues does this PR fix or reference?

#58

The PR fulfills these requirements:

[ ] Tests for the proposed changes have been added/updated.
[ ] Code linting and formatting was performed.

Functionality Before

  • No Service Agent recipe existed in the repo
  • No tooling for agent user lifecycle (creation, placeholder replacement, cleanup)

Functionality After

  • Complete CustomerServiceAgent recipe deployable via sf project deploy start --source-dir
    force-app-service
  • Automated agent user setup: npm run setup:service-agent creates the user and wires it into
    .agent files
  • Pre-commit hook auto-restores placeholder so org-specific values never reach the repo
  • CI passes the agent username between steps via GITHUB_OUTPUT — no grep, no file path coupling
  • Dedicated Customer_Service_Agent_Data permission set deploys with force-app-service,
    eliminating the cross-directory dependency

…ment

Promotes the CustomerServiceAgent from future_recipes to a new
force-app-service/ package directory typed as AgentforceServiceAgent.
Adds cross-platform Node.js scripts to create the org-specific agent
user and inject it into .agent files at deploy time, with a pre-commit
hook to restore the placeholder before commits. CI workflows updated
to deploy service agents sequentially after employee agents.

Closes #58
…d install scripts

The service agent user needs the data permset to access recipe objects.
Previously this was a vague post-install note. Now it's automated in CI
workflows, install scripts (sh + bat), and documented as an explicit
README step with the exact command.
… reduce to 3 subagents

The recipe now focuses on demonstrating the Service Agent differentiator
(agent_type + default_agent_user) with a clean 3-subagent flow:
router → triage → resolution. Drops unused update_case and
send_satisfaction_survey actions along with their backing metadata.
Moves all CustomerServiceAgent metadata into
force-app-service/customerServiceAgent/ to match the per-recipe folder
structure used in force-app/main/. Adds a detailed recipe README and
updates all path references in CI, install scripts, and AGENTS.md.
Without collect_info, the available when guards on all triage actions
stayed permanently locked because nothing wrote user input into
variables. The LLM now calls collect_info first to extract customer_id
and issue_description, which unlocks downstream actions.
…ploy failure

Move IssueClassifier class access and Contact.Customer_ID__c,
Contact.Loyalty_Tier__c, Case.Escalation_Reason__c field permissions
into a dedicated Customer_Service_Agent_Data permission set inside
force-app-service. This eliminates the deploy error where the shared
permission set in force-app referenced fields that only exist in
force-app-service.
… stdout

- Move node scripts (setup-service-agent, clean-service-agent,
  validate-agents) from bin/ to scripts/
- setup-service-agent now writes username to stdout and logs to stderr,
  eliminating the brittle grep against .agent files in CI
- CI steps capture username via GITHUB_OUTPUT step outputs
- Add clean:service-agent npm script
- Activate EscalateCase flow
- Remove .vscode bin exclusion
@msrivastav13 msrivastav13 requested a review from a team as a code owner May 7, 2026 04:21
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

CreateCase only accepts subject and outputs case_number (not case_id).
EscalateCase is a stub that returns hardcoded outputs without DML.
@msrivastav13 msrivastav13 changed the title Feat/service agent recipe with dx pipeline Feat: service agent recipe with dx pipeline May 7, 2026
@msrivastav13 msrivastav13 changed the title Feat: service agent recipe with dx pipeline feat: service agent recipe with dx pipeline May 7, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

@msrivastav13 msrivastav13 added bug Something isn't working enhancement New feature or request labels May 7, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

@muenzpraeger
Copy link
Copy Markdown
Contributor

Thanks for adding this @msrivastav13. I wonder if this shouldn't be a standalone example repo somewhere (similar as we have in Coral Cloud), as recipes are meant to be for Agent Script specifics.

@msrivastav13
Copy link
Copy Markdown
Contributor Author

msrivastav13 commented May 7, 2026

Thanks for adding this @msrivastav13. I wonder if this shouldn't be a standalone example repo somewhere (similar as we have in Coral Cloud), as recipes are meant to be for Agent Script specifics.

I think it can go either way.

In my opinion this is all still Agent Script specifics. It shows Agent Script of type AgentforceServiceAgent. Also it repurposes existing customerServiceAgent that was stale in future recipes folder because the user changes per org and the DX did not have support for it until lately.

By having a framework like this we can show Agent Script specifics like linked variables that are exclusive to AgentforceServiceAgent that we wont be able to show otherwise.

The other idea is we could make Service Agent class of recipes optional and then its up to the developers to decide to follow those along...Thoughts on this approach?

@pozil pozil removed the bug Something isn't working label May 7, 2026
@pozil
Copy link
Copy Markdown
Contributor

pozil commented May 7, 2026

Thanks for taking care of this @msrivastav13, I was also looking into it for an updated Coral Cloud demo with the new builder.
I agree that we should a have it in recipes because there are specific service agent patterns that we can showcase and if we stick to our previous decision, we won't update Coral Cloud.

The PR looks good but my experiments showed that you also have to update the agent username in the related *.bot-meta.xml files as well (see screenshot):
Screenshot 2026-05-07 at 14 29 36

@msrivastav13
Copy link
Copy Markdown
Contributor Author

Thanks for taking care of this @msrivastav13, I was also looking into it for an updated Coral Cloud demo with the new builder. I agree that we should a have it in recipes because there are specific service agent patterns that we can showcase and if we stick to our previous decision, we won't update Coral Cloud.

The PR looks good but my experiments showed that you also have to update the agent username in the related *.bot-meta.xml files as well (see screenshot): Screenshot 2026-05-07 at 14 29 36

@pozil Is it not a bug then in the Agent Script transformation to Bot metadata? Because this takes care of populating that user on the Agent Script level and my assumption is we do not ever have to deal with that Bot metadata.

Let me know and I think we can talk to DX team if this is something that can be done at CLI level itself

@pozil
Copy link
Copy Markdown
Contributor

pozil commented May 7, 2026

IDK what's the expected behavior but I guess that the bot metadata is created when you activate the service agent.
I had this issue when I was setting up my demo, the deploy would fail because it was missing the bot metadata.
Perhaps we don't need it if we refrain from activating the service agent?

@msrivastav13
Copy link
Copy Markdown
Contributor Author

IDK what's the expected behavior but I guess that the bot metadata is created when you activate the service agent. I had this issue when I was setting up my demo, the deploy would fail because it was missing the bot metadata. Perhaps we don't need it if we refrain from activating the service agent?

Yes for testing this out in my scratch org, I did not face this issue. I am on Summer orgs. I was able to commit of the UI because deploys were successful and then activate all fine.

Test this recipe out @pozil in a org and let me know if you see gaps.

@pozil
Copy link
Copy Markdown
Contributor

pozil commented May 7, 2026

I confirm that it works with the agent in draft mode (no need for the bot metadata update).

However, the escalation use case example from the readme didn't work on my end: it didn't escalate because it found an [unrelated] knowledge base article.
Screenshot 2026-05-07 at 16 29 04

@msrivastav13
Copy link
Copy Markdown
Contributor Author

I confirm that it works with the agent in draft mode (no need for the bot metadata update).

However, the escalation use case example from the readme didn't work on my end: it didn't escalate because it found an [unrelated] knowledge base article. Screenshot 2026-05-07 at 16 29 04

Thank you for testing. Will get this feedback addressed.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

@msrivastav13
Copy link
Copy Markdown
Contributor Author

I confirm that it works with the agent in draft mode (no need for the bot metadata update).
However, the escalation use case example from the readme didn't work on my end: it didn't escalate because it found an [unrelated] knowledge base article. Screenshot 2026-05-07 at 16 29 04

Thank you for testing. Will get this feedback addressed.

@pozil I did some more iterations on the instructions and the script. Let me know if you see anything else.

Copy link
Copy Markdown
Contributor

@pozil pozil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good apart from the API version. I'll let you merge directly once it's fixed.

<?xml version="1.0" encoding="UTF-8" ?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>66.0</apiVersion>
<apiVersion>60.0</apiVersion>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msrivastav13 can you revert this and make sure that we're on the latest API version for all metadata?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I updated this. @muenzpraeger Anything special needs to be done to show on the agent script recipes?

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Salesforce Code Analyzer found 82 violations, including 0 in files changed by this pull request. See job summary page.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants