Custom skills

What Happens When an AI Assistant Tries to Reserve a Spare Part?

Design a reservation skill around structured inputs, permission checks, concurrent stock changes and verifiable outcomes.

A stock check is a snapshot

“Find the right connector for this job and reserve two from the depot.” To the technician, that is one request. To the system, it contains a lookup for compatibility, a stock read and an inventory write. Each step can fail in a different way.

This is a hypothetical reservation design using the field-service setting of the Cortex IR solar demo. The demo shows a parts order against sample inventory. For a reservation, imagine the stock lookup returns two available units. Between that read and the write, another technician reserves one. At that point the inventory service has to decide whether the requested reservation can proceed.

Resolve the inputs before calling the write skill

Keep finding parts and checking availability separate from reserving inventory. Use an authoritative compatibility source and obtain the job, part and depot identifiers from resolved records. If “the depot” could mean two locations or the part fits only one of two installed revisions, ask a specific question before calling the write.

A narrow reservation input might contain a job ID, part ID, depot ID and positive integer quantity. The connected service still checks that those identifiers are valid together. Take the authenticated actor and scope from trusted application context. If policy calls for confirmation, show the resolved part, quantity, location and job before executing. When any of those details change, confirm the changed intent according to that policy.

  • Availability Can this assistant offer a reservation skill to this user?
  • Invocation Is the caller still authorised for this operation, job and depot? Recheck the applicable permission at execution time.
  • Business validity Does this part fit this job and can this depot reserve the requested quantity under its current conditions?

Read the proposed reservation back to the technician

Imagine job J-1042 is assigned to a technician who can reserve stock from the North depot. A catalogue search returns part CP-17, which fits the unit in the job record. The stock service shows two available at North and six at West. The phrase “from the depot” could refer to either location, and the rules for transfer and pickup differ. If the job has an approved default depot, state the default in the confirmation. Otherwise, ask which location the technician means.

A confirmation might read, “Reserve two CP-17 connectors at North for job J-1042?” If the technician replies, “Actually make it one at West,” treat that as new input. Resolve West, check authority for the changed location, and apply your policy for confirming the updated request. The first approval applies to the first set of parameters. Make the intent visible in the application so that a generic “yes” in a later turn cannot be attached to an unrelated reservation.

Permission and approval have different owners in this design. The approval records what the technician wants to do. Authentication and authorisation determine what the actor is allowed to do. The inventory service checks whether the operation is possible under current stock and job rules. Keeping those facts separate makes it easier to give a useful rejection and diagnose a disputed operation.

Make the stock decision at the point of commitment

The inventory service owns concurrency. Have it atomically check the stock condition and create the reservation, for example with a transaction or a conditional update against the authoritative inventory record. When only one unit remains, the original request for two should receive a conflict or a business rejection with a useful reason. If one unit is an acceptable alternative, present it as a new option and wait for the technician to choose it.

A dropped response poses a different problem. The write may have succeeded before the connection closed. Give the operation an idempotency key supplied by the application and bound to one confirmed intent. On a retry, the service should return the existing outcome for that intent or reject a reused key with different parameters. Record the key and the state change consistently. If the integration cannot deduplicate or reconcile, report the outcome as unknown and route it for checking before another write.

The inventory service decides the outcome. When a response is lost, look up or reconcile the original operation before retrying.

Follow the same request through three outcomes

These examples use fictional identifiers and outcomes. They illustrate why application code should read structured status and reference fields rather than rely on whether a call completed or returned a message containing the word “success”. A response that says “accepted for processing” belongs in an in-progress state until the system of record confirms its outcome.

  • Both units are available The inventory service commits the stock hold and returns reference R-782 for job J-1042. The response can report the quantity, depot and reference, plus an expiry if the service supplies one. The assistant can use that reference for later status checks.
  • Another technician takes one unit The service refuses the original two-unit request. The assistant says that North can no longer hold both and offers to check alternatives. If the technician chooses one unit at North and one at West, confirm the new plan and define how the integration will handle a partial success before issuing separate writes.
  • The client times out The client receives no confirmation. It checks the original operation using the same intent identifier. If the service finds R-782, report it. If the operation is still pending, say so. If the service cannot tell, say the reservation could not be confirmed and route it for reconciliation. Generating a fresh identifier and submitting the order again can create a second reservation.

Make the response match the committed outcome

Use explicit outcome fields in the skill contract so the assistant does not have to infer success from prose. An operation reference also gives support staff a way to reconcile issues with the inventory system.

  • Committed Say what was reserved, the job and depot it belongs to, and the reservation reference returned by inventory. Include an expiry if the service provides one.
  • Rejected Describe the reason returned by the service. If stock fell to one, explain that two could not be reserved and ask whether to look for alternatives.
  • Unknown State that confirmation has not come back and check the status of the original operation. An unconfirmed write should never be presented as a successful reservation.

Test the cases a clean demo skips

Test a user who can see stock but lacks reservation permission, a job outside the user’s scope, permission revoked between lookup and write, and two technicians competing for the same last unit. Then simulate a timeout after commitment and replay the same key. The duplicate request should resolve to the original reservation. Try the same key with a different quantity and verify the service rejects it.

Design for what happens after the reservation

A reservation can expire, be picked up, be cancelled or be consumed by a work order. If the workflow supports those operations, give each one a clear owner and contract. A cancellation should reference the original reservation and verify its current state. If the technician asks “Can you let it go?” after discussing two reservations, resolve which one they mean before releasing stock.

Updating the job system is a separate action. The stock reservation can succeed while the job status update fails. In that case preserve the reservation reference and report the job update separately so an operator can reconcile the two systems. Decide whether the workflow should retry the update, queue an administrative task or release the hold under an explicit rule. Re-running the entire workflow can duplicate a successful write.

For support, retain the operation identifier, the result code and approved references according to your retention policy. Exercise a handoff in testing. An operator should be able to find R-782 and understand why the job still has its previous status. Make the assertions against the connected service as well as the chat response. The same story should hold in both places.

Decide what happens when a technician returns to the conversation later and says, “Is it still reserved?” Fetch the current status by reference. A response saved earlier may still say “reserved” after the hold expires, and a stale confirmation could send the technician to the depot for stock that is no longer theirs. Test that a released or expired reference gets a fresh status check and a clear explanation. If the technician wants to reserve again, capture a new intent and rerun the relevant checks. The ability to distinguish a status lookup from a new write is part of the skill boundary.

Where Cortex IR fits

Cortex IR can expose configured operations as custom skills with structured inputs. Skill policy applies when the skill is selected and again at invocation. The connected inventory system is responsible for availability, atomic reservation, idempotency and reconciliation. Those guarantees belong in the integration contract and its tests.

Contact Cortex IR