Compatibility: Pactmark 0.1.x.
@pactmark/ai-sdk demonstrates Vercel AI SDK integration
as an optional peer dependency; its types never enter core APIs.What an adapter is responsible for
A model adapter normalizes five things and nothing else:Streamed content
Provider chunks become a bounded, countable stream the runtime can enforce limits against.
Tool requests
Provider tool-call shapes become a
tool_call referencing a registration digest.Finish reasons
Normalized so the runtime can distinguish “done” from “ran out of tokens”.
Usage accounting
Input and output usage, with an explicit failure when it cannot be accounted for.
Retry classification
timed_out, retryable or uncertain — the third one is not a synonym for the second.Nothing else
An adapter does not decide policy, resolve credentials for other calls, or write events.
The two profiles you must declare
modelSecurityProfileDigest, which travels with the accepted work order — so a change of region,
retention or training posture is a visible identity change rather than a quiet one.
Credentials
Figure 1. The runtime takes a pessimistic model-call reservation first, then issues a short-livedModelCredentialRef bound to that specific call. The adapter resolves it and nothing
else.
Retry classification is a safety decision
retryable
duplicates work; classifying a retryable one as uncertain parks runs that could have proceeded.
A model call that ends uncertain retains its maximum charge in the reservation. That is
deliberate: the alternative is a crash-loop that leaks budget.
Deterministic models for tests
You do not need a provider key to test agent behaviour, and you should not want one in CI:Registration and drift
A model adapter registration binds provider, model factory, security and resource profiles, endpoint, implementation version and source digest. Changing any of them changes the digest, and a run accepted against the old one will not silently continue against the new one —KAF_MODEL_ADAPTER_MISMATCH.
Observability and privacy
What may be recorded about a model call, and what may not.
Testing agents
Building deterministic scenarios around a fake driver.