Skip to main content
Use the AAP and AIP SDKs to add alignment verification and integrity checking directly to your application code. This gives you full control over when traces are generated, how integrity checks run, and what happens on violations. For governance features (policy enforcement, violation reclassification, trust recovery), use the Policy API and Reclassification API alongside the SDKs.
These quickstarts are available in Spanish (Español) and French (Français) — six pages per language have been translated.

Install

--legacy-peer-deps is needed on npm 7+ while @mnemom/agent-integrity-protocol 1.3.0 still declares an optional peer on the 1.x alignment-protocol package; the two SDKs work together at 2.0.0 / 1.3.0.
1

Define an Alignment Card

An Alignment Card declares your agent’s identity, values, autonomy boundaries, and audit commitments. Every trace and integrity check is verified against this card.
Field names changed in the unified card shape (AAP 2.0.0). aap_version is now card_version (date-anchored); autonomy_envelope/AutonomyEnvelope is now autonomy/Autonomy; audit_commitment/AuditCommitment is now audit/Audit; autonomy_mode and integrity_mode are new top-level fields; principal.identifier is required whenever principal.type isn’t unspecified; and audit.queryable: true requires audit.query_endpoint. See migrating from the legacy 0.5.0 card shape for the full mapping.
The Alignment Card is the foundation of both protocols. Define it once and use it for AAP verification, AIP integrity checking, and value coherence checks.
2

Generate AP-Traces from agent actions

Every significant decision your agent makes should produce an AP-Trace. The trace records the action taken, alternatives considered, reasoning applied, and whether escalation was evaluated.
Verification matches action.name against bounded_actions, not action.type. Both fields serve different purposes: type is a semantic category; name is the specific operation identifier checked against the card’s bounded_actions list.
3

Verify traces against the card

Verification checks whether the agent’s behavior (recorded in the trace) is consistent with its declared alignment (the card). It returns structural checks, a similarity score, and any violations or warnings.
The similarity_score (0.0 to 1.0) measures how semantically similar the trace’s behavior is to the declared alignment. A trace can pass all structural checks but still receive a low_behavioral_similarity warning if the score falls below 0.50. See calibration for how thresholds were derived.
4

Add integrity checkpoints

AIP integrity checking analyzes LLM thinking blocks per turn to detect prompt injection, value drift, and manipulation. Each check produces a verdict: clear, review_needed, or boundary_violation.
AIP defaults to fail-open mode. If the analysis LLM is unreachable, integrity checks will silently pass. For production deployments handling sensitive operations, set failure_policy: { mode: "fail_closed" } in your AIP configuration.
A client does the extraction, the LLM call, and the checkpoint/window bookkeeping for you — hand it the raw provider response body, not a pre-extracted thinking string. The card here is AIP’s own minimal card shape (card_id, values, autonomy_envelope) — a small subset of fields, kept separate from the full AAP AlignmentCard you built in Step 1, since @mnemom/agent-alignment-protocol is only an optional peer dependency for AIP.
client.check() runs the full pipeline every call: extract the thinking block for the detected provider, call the analysis LLM, parse the verdict, update the sliding window, and detect drift. There is no separate low-level “just parse this analysis response” function in the public API — check() is the one entry point.

Verdict to Action Mapping

5

Check value coherence

Before your agent collaborates with another agent, verify their values are compatible. Coherence checking compares declared values and detects conflicts.

Automatic tracing with decorators (Python)

The AAP Python SDK provides decorators for automatic trace generation:

Drift detection

Monitor your agent for behavioral drift over time:

Next steps