Bind Bedrock Batch Retries to One Client Request Token
Amazon Bedrock CreateModelInvocationJob accepts an optional clientRequestToken that makes repeated submissions idempotent. A safe batch client creates the token before attempt one, binds it to a canonical request digest, and reuses both after ambiguous transport failures. This guide keeps provider idempotency, local retry state, and the returned job ARN separate while limiting DeepInspect to the authenticated HTTP submission boundary.

Amazon Bedrock CreateModelInvocationJob accepts an optional clientRequestToken. AWS uses that case-sensitive value to keep the API request from completing more than once. The useful engineering work happens before the first POST: mint one token for the logical submission, bind it to the final job fields, and preserve it when a timeout leaves the response unknown. A retry with a fresh token asks Bedrock to create another job.
TL;DR
- Create one
clientRequestTokenbefore the firstCreateModelInvocationJobattempt and reuse it for every retry of that logical submission. - Bind the token to a canonical digest of the final job request. Reject local reuse when any bound field changes.
- Record each HTTP attempt separately, then attach the returned
jobArnto the parent submission record. - Keep job execution with AWS. Submission idempotency says nothing about S3 reads and model processing. Output writes and downstream consumption need their own controls.
The Bedrock token controls one create request
The Amazon Bedrock CreateModelInvocationJob API reference defines clientRequestToken as an optional, unique, case-sensitive identifier. AWS says it ensures that the API request completes no more than one time. When the token matches a previous request, Bedrock ignores the repeated request without returning an error.
The field accepts 1 to 256 characters under the documented pattern. Your application still needs a lifecycle design that defines when the logical submission begins, which fields belong to it, and which component owns the token.
Create the token before attempt one and persist it before sending the POST. Keep it stable through connection resets, worker restarts, load-balancer timeouts, and a retried 500 response. Generate a new token only for a new logical batch submission.
AWS's batch job creation guide lists the token as the optional API field used to ensure the request completes once. The same guide says the response returns a jobArn for later batch operations. Those identifiers serve different jobs: the client token deduplicates creation, while the ARN identifies the resource Bedrock accepted.
A request digest prevents token drift
Store a canonical digest beside the token. Build it from the final outbound fields that define the job, including jobName, modelId, invocation type, input configuration, output configuration, and roleArn. Include the timeout plus all VPC and tag settings. Canonicalization rules belong in versioned client code, with array ordering and omitted optional values handled consistently.
On every retry, rebuild the request and compare its digest with the stored value before attaching AWS credentials. A mismatch should enter a local conflict state. It should never become an experiment against provider behavior.
The Bedrock API page documents duplicate-token suppression but gives no token retention period. It also omits a scope statement and changed-parameter contract. The linked AWS idempotency guidance explains the general client-token model and warns against reusing a token for another request. Its EC2-specific mismatch rules should not be presented as a Bedrock promise.
My blunt opinion is that a token without a stored request digest is half an idempotency control. It can suppress one duplicate while leaving the application unable to prove what the token represented.
The LLM API parameter allowlisting guide applies the same final-payload discipline to provider fields selected at an authenticated HTTP boundary.
Ambiguous outcomes need a submission ledger
A client can lose the connection after Bedrock receives the POST and before the jobArn reaches the caller. Record that attempt as outcome_unknown, keep the original token and request digest, then send any permitted retry with the same final body. A second operation identity would defeat the control.
Use one parent record for the logical submission and one child record per HTTP attempt. The parent should retain caller identity, route, token, and canonicalization version. Add the request digest along with the policy version and final disposition. Each child records its attempt number, destination Region and endpoint, start time, deadline, and transport result. It also keeps the HTTP status plus gateway decision ID. Attach the returned jobArn to the parent when a response arrives.
Restrict token visibility in application telemetry and treat it as a correlation identifier with controlled access. Prompt data remains in the staged S3 input, and AWS credentials stay out of the ledger.
The safe idempotent LLM retries guide covers the wider operation-ledger pattern. For this Bedrock route, the provider token identifies the create operation. Attempt records and reconciliation keep their own state.
Retry policy stays narrower than idempotency
Idempotency answers the duplicate-create question. Retry eligibility comes from the Bedrock response and your application policy. Handle validation failures and access denials explicitly. Apply route policy to quota responses and conflicts. A transport failure or documented transient server error may qualify for a bounded retry with the original token and unchanged digest.
Set an attempt limit and an elapsed deadline around the logical submission, with every backoff delay consuming that budget. If the budget expires with an unknown result, stop automated creation and send the record to reconciliation or operator review. Minting a fresh token at that point discards the protection that made the earlier attempts safe.
Keep downstream effects separate too. A single Bedrock batch job can produce output that another worker imports or publishes before forwarding it elsewhere. The clientRequestToken governs creation through CreateModelInvocationJob; it never deduplicates those later consumers. Use the job ARN or a local operation ID under an explicit commit rule at each downstream boundary.
Release tests should break the response path
Run tests through the real HTTP client and retry wrapper. Include credential attachment plus the submission ledger. A provider stub should accept the first request, record its token and body digest, then close the connection before returning a response. The second attempt must carry the same token and byte-equivalent bound fields.
Add these fixtures:
- Crash the worker after persisting the parent record but before attempt one.
- Drop the connection after the provider stub accepts the request.
- Start two workers for the same logical submission and require one token owner.
- Change
modelId,roleArn, or an S3 URI under the stored token and require a local conflict. - Repeat that mutation for VPC settings, timeout values, and tags.
- Return a validation or access error and prove the client avoids automatic replay.
- Return a transient server error, then succeed under the same token and deadline.
- Deliver the successful response twice and attach one
jobArnto the parent record. - Exhaust the retry budget and preserve
outcome_unknownfor reconciliation.
On the release screen, put the full token in monospace above the request digest. Show the jobArn beneath them after acceptance. Highlight a changed field in red beside the stored value, so a reviewer can see token drift without opening a raw JSON trace.
The AI audit log schema guide provides the caller, route, policy, and correlation fields that can join the submission ledger to an independent policy decision.
DeepInspect
DeepInspect can inspect authenticated user or agent HTTP requests deliberately routed to CreateModelInvocationJob. It can require a valid client token, bind that token to the final serialized request digest, reject changed-field reuse under route policy, and record each routed attempt with the caller and decision context.
AWS owns token handling after the request reaches Bedrock and runs the accepted batch job. The application owns token generation, persistence, retry budgets, reconciliation, job monitoring, and downstream deduplication. Direct SDK calls, console submissions, and HTTP paths that bypass the proxy remain outside DeepInspect's enforcement boundary.
Book a technical deep dive at deepinspect.ai.
Frequently asked questions
- Is clientRequestToken required by CreateModelInvocationJob?
AWS marks
clientRequestTokenoptional. Production clients that may retry a batch creation request should supply one because a fresh or absent token leaves duplicate creation unresolved after an ambiguous transport failure. Create and persist the token before the first attempt.- Can a retry change the batch job fields?
Treat changed fields as a new logical submission with a new token. For an existing token, compare the rebuilt request digest with the stored digest and reject any mismatch locally. The Bedrock API page does not document changed-parameter behavior for this operation, so the client should avoid depending on an unstated provider result.
- Does the token prove the batch job completed?
The token proves only idempotent creation at the API boundary. Bedrock owns later model processing and job state. S3, IAM, KMS, and the batch service role govern post-submission access. Monitor the job by its
jobArnand verify the required output evidence separately.- Should the token and job ARN share one database column?
Use distinct database fields for these values. The client creates
clientRequestTokenbefore submission. Bedrock returnsjobArnafter accepting the job. Separate columns preserve that direction of authority and allow an unknown outcome to exist before the ARN is available.