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:
- Missing or unmapped
changeJobWidon the Custom Agent Action End step: In a two-step staffing pattern (whereinitiate_change_jobstarts 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 extractedchangeJobWid, the model sees a null WID, concludes the initiation didn’t produce the required identifier, and immediately callsinitiate_change_jobagain. - Silent SOAP Fault or HTTP 200 validation error inside the orchestration:
Send Workday API RequestmarksisSuccess = truewhenever Workday returns an HTTP response, including when a SOAP call returns aSOAP-ENV:Faultor when a sub-step fails afterInitiate_Change_Jobhas 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. - Unannotated or retry-permissive skill instructions: Without explicit Action Annotations (
Destructive) on the Custom Agent Action and a single-call guard in the.agentskillStepsprompt, 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:
- In Orchestration Builder, extract the event WID after the
Initiate_Change_JobSend 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']", "") - On the orchestration’s End step, click Configure Response.
- On the Body tab, add explicit output parameters:
changeJobEventWid(String),status(String), anderrorMessage(String). - 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:
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:
## 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.