docs: spike findings on prompt caching in Bedrock batch extraction - #7
Open
noel-improv wants to merge 2 commits into
Open
noel-improv wants to merge 2 commits into
noel-improv wants to merge 2 commits into
Conversation
|
Lexical Graph Coverage Report: The coverage is at 59.68% (target: 80%). Download the HTML report here. |
noel-improv
force-pushed
the
spike/prompt-caching-batch-extraction-AN-3362
branch
from
June 22, 2026 19:23
4eddce4 to
db2e696
Compare
|
Lexical Graph Coverage Report: The coverage is at 59.67% (target: 80%). Download the HTML report here. |
Document the finding that AWS Bedrock does not support prompt caching with the batch inference API (CreateModelInvocationJob); caching is on-demand only. Confirmed against the AWS prompt-caching guide, batch-inference limitations page, and API reference. Marks the finding as documentation-confirmed with an empirical confirmation run planned, removes unverified token estimates, and describes the planned two-arm (on-demand control + batch) test.
noel-improv
force-pushed
the
spike/prompt-caching-batch-extraction-AN-3362
branch
from
June 23, 2026 16:40
db2e696 to
3126dc7
Compare
|
Lexical Graph Coverage Report: The coverage is at 59.68% (target: 80%). Download the HTML report here. |
|
Lexical Graph Coverage Report: The coverage is at 59.68% (target: 80%). Download the HTML report here. |
noel-improv
force-pushed
the
spike/prompt-caching-batch-extraction-AN-3362
branch
from
September 3, 2026 15:59
c78ae75 to
89e936d
Compare
|
Lexical Graph Coverage Report: The coverage is at 64.23% (target: 80%). Download the HTML report here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spike outcome
AWS Bedrock does not support prompt caching with the batch inference API. Caching is on-demand only. The toolkit's batch extractors submit work through
CreateModelInvocationJob(S3-in, S3-out, asynchronous), so acache_control/cachePointmarker in a batch record is inert. The batch-path token-cost or latency win this spike investigated is not achievable.This tests the central assumption in the DRAFT issue awslabs#326 (Proposed Solution point 2: "Bedrock Batch Inference supports prompt caching when the system prompt is consistent across records"). The spike refutes it. The issue's own Current State note already flagged that the per-record JSONL format has no cache hints.
Verification status
Confirmed two ways. Documentation: the prompt-caching user guide (verbatim: "It is not supported with the batch inference API"), the batch-inference limitations page, and the
CreateModelInvocationJobAPI reference. Empirical: a two-arm test onus.anthropic.claude-sonnet-4-6.The empirical result is stronger than the docs imply. The on-demand control passed — an
InvokeModelcall using the exact body shape a batch record carries (cache_control: ephemeralon the first content block) wrote then read ~4,240 cache tokens on a repeated prefix, proving the marker placement is valid. The batch arm then submitted those same records throughCreateModelInvocationJob: all 100 failed witherrorCode 400("your request did not allow prompt caching"),successRecordCount: 0. So batch does not silently drop the cache directive — it rejects the request. The identical body caching on-demand isolates the batch API as the sole cause.One measured caveat: the effective cache-checkpoint minimum for Sonnet 4.6 behaved like ~4,096 tokens, not the 1,024 the AWS table lists (a ~1,400-token prefix did not cache).
What's in this PR
A findings document at
lexical-graph/docs/spikes/prompt-caching-in-batch-extraction.md. No production code change, because there is nothing to add to the batch path.Follow-up (out of scope here)
Caching is supported on the non-batch / on-demand extraction path (issue awslabs#326 point 1), which this ticket excludes. Two structural facts hold now: the instruction block leads both prompts (a single checkpoint at its end captures the reusable span), and neither prompt contains few-shot examples (the static content is instructions only). Backlog ticket deferred until the team reviews these findings.
Incidental
A pre-existing malformed system-role literal in the Claude batch branch (
'role': 'system\"') was found during review and fixed independently in awslabs#331.References