Skip to content

fix(eve): support explicit prompt-cache-path override for opaque Bedrock inference profiles (#1314) - #1415

Open
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/bedrock-inference-profile-prefix-1314
Open

fix(eve): support explicit prompt-cache-path override for opaque Bedrock inference profiles (#1314)#1415
iroiro147 wants to merge 1 commit into
vercel:mainfrom
iroiro147:fix/bedrock-inference-profile-prefix-1314

Conversation

@iroiro147

@iroiro147 iroiro147 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1314.

Eve inferred the Anthropic-direct prompt-cache path for AWS Bedrock only when the resolved model id contained the substring anthropic. Bedrock application inference profile ids can be opaque and omit the underlying provider family, so an Anthropic model reached through such a profile was misclassified as none — the stable system/tool prefix received no Bedrock cache points, and repeated turns were billed as fully uncached input.

Plain Anthropic foundation-model ids kept working only because they happen to include anthropic. Inferring provider family from an opaque deployment identifier is not reliable.

What changed

detectPromptCachePath now honors an explicit, supported, per-model override declared under the eve-owned namespace in the model's options:

export default defineAgent({
  model: bedrock("arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123"),
  modelOptions: {
    providerOptions: {
      eve: { cachePath: "anthropic-direct" },
    },
  },
});
  • eve.cachePath accepts "anthropic-direct" (force the Anthropic breakpoint path) or "none" (opt the model out of caching).
  • An explicit value takes precedence over inference; models without an override keep their existing automatic detection unchanged (direct Anthropic providers, @ai-sdk/amazon-bedrock Anthropic model ids, Vertex Anthropic).
  • An unrecognized value fails fast at turn start, so a mis-declared cache path is loud instead of silently uncached.
  • The override is read from the active model reference's providerOptions, so it stays per-model correct for dynamic-model agents with a scoped selection.

This mirrors the existing eve-namespaced providerOptions.gateway.byok hint pattern and preserves the public defineAgent / compiled-manifest schema — it rides the already-validated open providerOptions bag rather than adding a new top-level key.

Why this design (smallest supported override)

I considered two narrower alternatives and rejected them: a providerFamily boolean forces a fake family onto models it can't know and silently no-ops elsewhere; an opaque-id heuristic keeps doing substring inference, which this issue shows is unreliable. An explicit cache-path override is the smallest supported surface that solves the opaque-profile case while leaving the inference path untouched.

Validation

Command Result
pnpm --filter eve typecheck
pnpm lint (oxlint)
Scoped unit — prompt-cache + tool-loop + step-hooks + prompt-cache-accounting ✅ 212 passed
Targeted new tests for this change ✅ 6 — opaque profile (no override) → none; opaque profile + anthropic-direct override; explicit-override precedence; none opt-out; fallback-to-inference; invalid override throws; non-Anthropic unchanged
Full packages/eve unit tier ✅ 5660/5665 — the only 4 failures are test/bin-bootstrap.test.ts asserting the Node >=24 engine contract while this shell runs Node v22.22.3 (pre-existing ambient mismatch; bin/eve.js declares the same requiredRange guard on pristine main, and that file is not touched by this change)

Notes for reviewers

  • The override is namespaced to eve (provider SDKs don't consume it), so it carries a framework hint without changing the provider's request semantics.
  • I did not change automatic detection for any currently-working configuration; this only adds an opt-in override for identifiers inference cannot classify.

Authoring: drafted under the Codex6 planning chain with an independent-reviewer gate; full review ledger (GLM-5.2/GRID + Codex6 admission attempts, findings, machine gate) is recorded and available. Happy to route a fresh GLM-5.2 independent re-review on request.


Maintainer note — DCO, base freshness, and the two "fail" checks

  • DCO ✅ — commit is signed off (git commit -s), matching the PR author identity.
  • Rebased onto current main (5ff5534) so the diff is clean and current.
  • Vercel – eve-docs / eve-docs-4759 "Authorization required to deploy" and the four agent-prompt-cache e2e runners: these are the standard external-fork secret/deploy gate, not a code regression. On a maintainer-authorized run they should behave exactly as on a same-repo branch. Evidence this change does not regress the prompt-cache path:
    • The agent-prompt-cache e2e fixture authors a direct anthropic(...) instance with no override, so this change is a strict no-op on that code path (readCachePathOverride(undefined)undefined → unchanged inference → anthropic-direct).
    • The failure itself is environmental: the job ran with an empty AI_GATEWAY_API_KEY, fell back to Vercel OIDC, and failed with VercelOidcTokenError: x-vercel-oidc-token header is missing / Unable to find project root (... vc link), producing 0 tool calls and a NaN% cache rate. For comparison, same-repo PR fix(eve): make turn cancellation reliable for sessions parked on subagents #1389 ran these exact agent-prompt-cache runners to pass with the gateway secret present.
    • Everything controllable from a fork is green: lint, typecheck, test-unit, test-integration (ubuntu), changes, Socket, Vercel Agent Review.

Happy to push any adjustment a maintainer-authorized CI run surfaces.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@iroiro147 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@iroiro147
iroiro147 force-pushed the fix/bedrock-inference-profile-prefix-1314 branch from 3ac2146 to 6849c43 Compare July 30, 2026 17:17
…ock inference profiles

Resolves vercel#1314.

detectPromptCachePath inferred the Anthropic-direct prompt-cache path for
Bedrock solely from the resolved model id containing "anthropic". AWS Bedrock
application inference profile ids can be opaque and omit the underlying
provider family, so an Anthropic model reached through such a profile was
classified as `none`: the stable system/tool prefix received no Bedrock cache
points and repeated turns were billed as fully uncached input.

Detection now reads an optional, strictly-validated override from the eve-owned
namespace on the model's authored options:

  modelOptions.providerOptions.eve = { cachePath: "anthropic-direct" | "none" }

The explicit override takes precedence over inference; models without it keep
their existing automatic behavior (direct Anthropic providers,
@ai-sdk/amazon-bedrock Anthropic model ids, Vertex Anthropic). An unrecognized
value fails fast at turn start so a mis-declared cache path is loud rather than
silently uncached. The override is read from the active model reference's
providerOptions, so it stays per-model correct for dynamic-model agents with a
scoped selection.

Mirrors the existing eve-namespaced `providerOptions.gateway.byok` hint pattern
and preserves the public defineAgent/manifest schema (rides the open
providerOptions bag). Includes targeted unit tests, a changeset, and user docs.

Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
@iroiro147
iroiro147 force-pushed the fix/bedrock-inference-profile-prefix-1314 branch from 6849c43 to d073ba9 Compare July 30, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt cache detection misses Bedrock application inference profiles

1 participant