---
title: "Prevent Duplicate Initiate_Change_Job Calls in Custom Agents"
description: "Why a Workday Custom Agent calling initiate_change_job to update a Contingent Worker contract triggers duplicate Change Job business process events, and how…"
url: https://kiweely.com/guides/workday-custom-agent-duplicate-initiate-change-job
---

# Preventing Duplicate Initiate\_Change\_Job Business Process Events When a Workday Custom Agent Calls a Write Tool

When a Custom Agent write tool calls Initiate\_Change\_Job without returning a clear Change Job business process WID in its response payload, the LLM assumes the call did not produce a WID and retries. Return the explicit event WID, set Destructive annotations, and check for in-progress events.

-   **Checked** against Workday on November 6
-   Applies to **Workday Orchestrate**
-   4 min read
-   Published November 6
-   By Kiweely

## Why `initiate_change_job` fires multiple times in a single agent turn

When building a Workday Custom Agent that updates a worker’s assignment—such as calling `initiate_change_job` to extend a Contingent Worker’s contract end date and retrieve the resulting **Change Job** business process event WID (`changeJobWid`) for subsequent step updates—developers frequently observe the agent invoking `initiate_change_job` two or three times in a single conversation turn. In the tenant, each invocation spawns a separate in-progress **Change Job** business process event on the worker, or fails on the second call because an overlapping staffing event is already in progress.

This duplicate firing happens because the large language model (LLM) driving the Custom Agent relies entirely on the structured tool output and the `.agentskill` instructions to decide whether a step succeeded:

1.  **Missing or unmapped `changeJobWid` on the Custom Agent Action End step:** In a two-step staffing pattern (where `initiate_change_job` starts the template-based Change Job event and returns the event WID so a follow-up step can populate contract end date details), if the Custom Agent Action orchestration’s **End** step (`Configure Response`) returns an empty body, an unparsed XML envelope, or a generic message without the extracted `changeJobWid`, the model sees a null WID, concludes the initiation didn’t produce the required identifier, and immediately calls `initiate_change_job` again.
2.  **Silent SOAP Fault or HTTP 200 validation error inside the orchestration:** `Send Workday API Request` marks `isSuccess = true` whenever Workday returns an HTTP response, including when a SOAP call returns a `SOAP-ENV:Fault` or when a sub-step fails after `Initiate_Change_Job` has already committed. If the orchestration catches or mishandles a downstream error after initiating the event, the LLM retries the entire tool call from the beginning.
3.  **Unannotated or retry-permissive skill instructions:** Without explicit **Action Annotations** (`Destructive`) on the Custom Agent Action and a single-call guard in the `.agentskill` `Steps` prompt, the agent treats the initiation tool as safe to retry automatically when any field in the response looks incomplete.

## Returning the Change Job event WID cleanly from the End step

If your Custom Agent uses a **Custom Agent Action** orchestration to call the Staffing REST `POST /workers/{ID}/businessProcessEvents` (`initiate_change_job`) or the Staffing SOAP `Change_Job_Request` / `Contract_Contingent_Worker_Request` web service, make sure the orchestration extracts the created business process event WID and exposes it as a documented output property on the **End** step:

1.  In Orchestration Builder, extract the event WID after the `Initiate_Change_Job` **Send Workday API Request** step using a **Create Values** step:
    
    javascript
    
    ```
    // For REST response JSON:
    data.InitiateChangeJob.response.asJSON().stringAtJsonPath("$.id")
    
    // For SOAP response XML:
    data.InitiateChangeJob.response.asXML().stringAtXpathWithDefault("//wd:Job_Application_Event_Reference/wd:ID[@wd:type='WID'] | //wd:Event_Reference/wd:ID[@wd:type='WID']", "")
    ```
    
2.  On the orchestration’s **End** step, click **Configure Response**.
3.  On the **Body** tab, add explicit output parameters: `changeJobEventWid` (`String`), `status` (`String`), and `errorMessage` (`String`).
4.  Switch to the **Custom Agent Actions** tab on the **End** step and write a clear description for each output property:
    -   `changeJobEventWid`: `The 32-character Workday ID (WID) of the newly initiated Change Job business process event. If this value is populated, the Change Job event has already been created in the tenant and MUST NOT be initiated again.`
    -   `status`: `Returns INITIATED when the Change Job event was created, or FAILED if Workday rejected the initiation.`

## Guarding against retries in Orchestrate and `.agentskill`

### 1\. Set the Action Annotation to `Destructive`

On the orchestration’s **Start** step > **Configure Request** > **Custom Agent Actions** tab, set **Action Annotations** to *Destructive* (and never *Read-Only*). Workday Custom Agents prompt the user to approve every call to a non-*Read-Only* action, which prevents the model from firing a second silent retry loop in the background without human confirmation.

### 2\. Check for an existing in-progress Change Job event before initiating

Inside your Custom Agent Action orchestration, add a lightweight WQL pre-check before the `Initiate_Change_Job` step to see if the contingent worker already has an in-progress Change Job event created today:

sql

```
SELECT workdayID, businessProcessTransactions{workdayID, overallStatus, transactionEffectiveMoment}
FROM workersForHCMReporting
WHERE workdayID = '{{lp.getSimpleData("workerWid")}}'
```

If an in-progress Change Job event already exists for that worker and effective date, return its existing `workdayID` in `changeJobEventWid` with `status = "ALREADY_INITIATED"` instead of creating a duplicate event.

### 3\. Add a strict single-invocation rule to `.agentskill`

In your `.agentskill` file, instruct the model never to call `initiate_change_job` more than once per request:

markdown

```
## Steps

1. Confirm the contingent worker's `workerWid` and the new `contractEndDate` (YYYY-MM-DD) with the user.
2. Call `initiate_change_job` **at most once**.
3. Inspect the tool output:
   - If `changeJobEventWid` is returned, proceed to update the contract end date using that WID.
   - If `initiate_change_job` returns an error or an empty `changeJobEventWid`, **stop immediately**, report the exact error message to the user, and do **not** call `initiate_change_job` a second time.
```

Also ensure any required prompt lookup tools (such as Change Job Reason prompt WIDs) are included in `tool-wids` alongside the write tool so the initiation doesn’t fail mid-flight on an invalid reason reference.

## Verifying the fix in your tenant

Open your Agent app in App Builder, trigger the contract end date change in Workday Chat, and open the **Agent Traces** tab at the bottom of App Builder. Click **View Trace Details** on the run and expand the `AviatoTurboChatCIS` node. In the **Outputs** section, verify that `initiate_change_job` appears only once in the tool call list and that its tool response includes the populated `changeJobEventWid`. Finally, open the contingent worker’s **Worker History** in the tenant to confirm that only a single **Change Job** business process event was created.

## Sources checked

-   [Configure Custom Agent Action Orchestrations](https://developer.workday.com/documentation/GUID-fce1f988-5cf6-4d0c-ad1a-953bcfe212c6)
-   [Agent Traces](https://developer.workday.com/documentation/GUID-4dc75ec0-717f-41c7-8ca3-30739edd5056-enHYPHENus)
-   [Agent-Ready Prompt Tools](https://developer.workday.com/documentation/GUID-bd1ec8d8-7bcf-40d9-a58a-aa805282ebe7-enHYPHENus)
-   [Troubleshoot Custom Agent Actions](https://developer.workday.com/documentation/GUID-71867a63-18bd-4b95-802c-2dc3cf90a3d1-enHYPHENus)
-   [Build and Deploy Custom Agents](https://developer.workday.com/documentation/GUID-c2e04f80-557a-4968-8957-9f1210156908-enHYPHENus)

## Related guides

[All guides](https://kiweely.com/guides)

-   [### Why a Workday Custom Agent Has No Credentials Tab in Agent Management Hub, and How to Expose It Through A2A Workday displays the Credentials tab in Agent Management Hub only for registered External Agents. To expose a Custom Agent built on Workday’s AI platform to an external assistant, register a third-party Agent Definition in the Agent System of Record that wraps the Custom Agent WID as an A2A tool.](https://kiweely.com/guides/workday-custom-agent-missing-credentials-tab-a2a)
-   [### Passing Large CSV File Attachments From a Workday Custom Agent Flow to Orchestrate Without Hitting Context Limits Passing a multi-thousand-row CSV directly through a Custom Agent Action JSON input forces the LLM to serialize the entire file inside its context window. Store the uploaded CSV in an Extend Attachment Business Object via a PMD fileUploader widget and pass only the Attachment WID to Orchestrate.](https://kiweely.com/guides/workday-custom-agent-csv-file-attachment-orchestrate)
-   [### Why Custom Agent Actions Fail With S22 Permission Denied or Task Not Authorized in Agent Chat Orchestration Builder runs Custom Agent Actions directly as your user, whereas Agent Chat enforces dual ASOR authorization and restricts the Agent System User token to the resources listed in your .agentskill file. Register every REST, SOAP, and WQL resource WID via the Finder API to fix it.](https://kiweely.com/guides/workday-custom-agent-actions-permission-denied-tool-wids)
-   [### Why Custom Agent Skills Deployed From the Developer Site Don’t Appear in Agent Management Hub, and ASOR Tenant Prerequisites When you deploy a Custom Agent with multiple .agentskill files from App Builder, Workday’s Agent System of Record packages all of their tools into a single combined skill registration that starts disabled. Learn how to enable and sync skills in Agent Management Hub and verify ASOR prerequisites.](https://kiweely.com/guides/workday-agent-management-hub-skills-not-showing)

### More guides on Custom agents and Workday AI

[All 91 guides](https://kiweely.com/guides#custom-agents)

-   [Fixing invalid\_request OAuth Token Exchange Errors When Connecting Microsoft Copilot Studio to Workday A2A](https://kiweely.com/guides/workday-a2a-copilot-studio-oauth-invalid-request)
-   [Fixing Workday Developer Agent VS Code Sign-In With a Personal Developer Account and Subagent Interrupt Errors](https://kiweely.com/guides/workday-developer-agent-vscode-personal-account-login)
-   [Finding Workday tool IDs with the Agent Resource Search (finder) API](https://kiweely.com/guides/workday-finder-api-tool-discovery)
-   [Connecting an Extend app to the Workday Self-Service Agent and Microsoft Teams](https://kiweely.com/guides/workday-extend-self-service-agent-teams)
-   [How to build a chatbot in Workday Extend](https://kiweely.com/guides/workday-extend-chatbot)
-   [How to call AI Gateway Document Intelligence from a Workday Extend app](https://kiweely.com/guides/workday-extend-ai-gateway-document-intelligence)
-   [Who gets Workday Developer Agent, and what it uses in Flex Credits](https://kiweely.com/guides/workday-developer-agent-access-flex-credits)
-   [Connecting a Workday custom agent to an outside agent platform with A2A](https://kiweely.com/guides/workday-custom-agents-a2a-external-agents)

### From the blog on Custom agents and Workday AI

[All posts](https://kiweely.com/blog)

-   [Turn an agent session into a job aid before the chat disappears](https://kiweely.com/blog/workday-job-aids-from-ai-agent-runs)
-   [App Builder vs Claude Code for Workday Developer Agent](https://kiweely.com/blog/app-builder-vs-claude-code-developer-agent)
-   [What to put in a Workday SOW when agents are in scope](https://kiweely.com/blog/workday-implementation-sow-ai-agents)

## Let Workday check the work.

Kiweely writes WQL and builds orchestrations in your own tenant, and Workday, not Kiweely, says whether they passed.

[Start for free](https://kiweely.com/download) [See how it works](https://kiweely.com/vine/how-it-works)

## Get the next guide in your inbox.

One email a month with new guides and one Extend tip. Nothing else.
