agent/. This integration adds two of those files: memory tools the model can call, and an instructions resolver that injects Synap’s short-term context into every turn.
eve’s own durability (Vercel Workflows) persists a single session’s turn state so it survives crashes and redeploys — that is short-term session state, not cross-session memory. Synap is the durable, cross-session layer on top. Tested against
[email protected] (AI SDK v7); eve is in beta, so pin your version.Overview
This guide shows how to add Synap to an eve agent so it can:- Recall long-term memory and store facts on demand, via tools the model chooses to call
- Automatically inject Synap’s compacted short-term context into the system prompt every turn
- Scope memory per user without the model ever seeing the identity
agent/:
The filename under
agent/tools/ becomes the model-facing tool name. The instructions resolver augments instructions.md — it adds a system message, it never replaces your prompt.
Setup
Install the package alongside eve:Import the integration from its package name directly:
import { createSynapSearchTool } from "@maximem/synap-eve". The core SDK (createClient) comes from the separate @maximem/synap-js-sdk package..env
agent/ files can share it:
agent/lib/synap.ts
Basic integration
The smallest useful integration is a single search tool. Drop this file in and the model can pull long-term context whenever it decides it needs it:agent/tools/synap_search.ts
user_id comes from ctx.session.auth.current.principalId and the conversation_id from ctx.session.id. On an authenticated channel that is all you need — the model never sees the user identity, and reads degrade gracefully (empty result on failure, so a recall miss never aborts the turn).
To also inject short-term context on every turn without the model asking, add the instructions resolver below.
Core concepts
Memory tools
Both tool factories return branded eveToolDefinitions. Search reads; store writes:
agent/tools/synap_store.ts
synap_search input: { query: string, maxResults?: number }. synap_store input: { content: string, metadata?: Record<string, unknown> }.
Error policy follows the Synap-wide contract:
synap_searchdegrades gracefully: returns{ available: false }and logs on failure.synap_storesurfaces failures: raisesSynapIntegrationError, so the model sees that an ingestion outage happened rather than assuming the write succeeded.
Short-term context resolver
createSynapInstructions returns a defineDynamic resolver that runs at the start of every turn, fetches Synap’s compacted short-term summary for the conversation, and lowers it to one extra system message:
agent/instructions/synap.ts
agent/instructions.md; it never replaces it. When there is no context — or on an SDK failure with the default onError: "fallback" — the resolver returns null, which eve treats as “contribute nothing,” and the turn proceeds unchanged.
Identity and scoping
Every factory accepts the standard scoping options, which override the session-derived defaults:
The integration deliberately does not fall back to the session initiator: on a delegated or system-initiated session that is whoever started it (an admin or service), not the end user the turn acts for — using it would scope memory to the wrong principal.
Complete example: memory-augmented agent
A complete agent that has always-on short-term recall AND lets the model search/store explicitly is just a few files:agent/agent.ts
agent/instructions.md
agent/instructions/synap.ts
- The resolver and the tools are complementary.
createSynapInstructionssets the always-on baseline; the tools handle the explicit “I should look this up / bookmark this” path. - Scope is derived per turn from the eve session — no per-request agent construction needed on authenticated channels.
- The instructions are the policy. Telling the model when to call
synap_search/synap_storeis what produces the explicit-memory behavior.
Advanced patterns
Unauthenticated channels
If a channel does not authenticate the caller (ctx.session.auth.current is null), the session-derived user_id is unavailable. Pass an explicit userId (and customerId for B2B) into the factories:
agent/tools/synap_search.ts
Latency vs. comprehensiveness
synap_search accepts mode:
Failure semantics
- Reads (
synap_search, the instructions resolver) degrade gracefully: empty result /null, logged. - Writes (
synap_store) surface failures: raiseSynapIntegrationError.
Going further
- Patterns overview: reusable memory patterns across frameworks.
- Cookbook overview: end-to-end worked examples.
Next steps
Vercel AI SDK
Model middleware for the Vercel AI SDK — the layer below eve.
Mastra
SynapMemory class and tools for Mastra.Context Fetch
The retrieval API behind
synap_search and the instructions resolver.Memory Scopes
How
userId, customerId, and conversationId interact across reads.
