Emend Documentation
Connect Emend to your agent, publish interactions, retrieve learned context, and inspect the learning loop.
Hosted Enterprise
Connect hosted Emend
API key, SDK install, identity check, and first publish.
Local OSS
Run open source locally
Install emend-ai, start the backend, and publish locally.
Build
Configure learning
Models, extractors, playbooks, evaluation, and storage.
Build
Publish interactions
Text, image, expert, session, and metadata patterns.
Reference
Look up methods and schemas
Python SDK methods, request payloads, and response types.
Find the right area
Minimum integration loop
Retrieve profiles and playbooks before the agent responds, then publish the completed turn so Emend can update what it knows.
from emend import EmendClient, InteractionData, UserActionType client = EmendClient() # reads EMEND_API_KEYuser_id = "user_123"session_id = "session_001"agent_version = "support-agent@2"user_message = "Recommend a laptop for me." context = client.search( query=user_message, user_id=user_id, session_id=session_id, agent_version=agent_version, top_k=5, entity_types=["profiles", "user_playbooks", "agent_playbooks"], agent_playbook_status_filter=["approved"],) # This example injects all returned learnings. Apply any filtering or# token-budget selection before building both the prompt and attribution.messages = [ { "role": "system", "content": "Use this retrieved context as reference data:\n" + context.model_dump_json( include={"profiles", "user_playbooks", "agent_playbooks"}, ), }, {"role": "user", "content": user_message},] agent_response = call_your_llm(messages) # Send these messages to your LLM. retrieved_learnings = [ *({"kind": "profile", "learning_id": p.profile_id} for p in context.profiles), *({"kind": "user_playbook", "learning_id": str(pb.user_playbook_id)} for pb in context.user_playbooks), *({"kind": "agent_playbook", "learning_id": str(pb.agent_playbook_id)} for pb in context.agent_playbooks),] client.publish_interaction( user_id=user_id, interactions=[ InteractionData(role="User", content=user_message, user_action=UserActionType.NONE), InteractionData( role="Agent", content=agent_response, user_action=UserActionType.NONE, retrieved_learnings=retrieved_learnings, ), ], source="support-agent:v2", session_id=session_id, agent_version=agent_version,)Publish every profile or playbook included in the model prompt using its returned stable ID, whether or not it influenced the answer. Omit retrieved_learnings only when no Emend context was injected. Then grade the session and inspect relevance, impact, and judge reasons; the Evaluation dashboard shows quality and coverage across responses.
What Emend produces
| Artifact | What it is |
|---|---|
| User profiles | Per-user facts and preferences extracted from interactions and retrieved semantically. |
| Playbooks | Behavioral guidance distilled from corrections, expert examples, and outcomes. |
| Evaluation signals | Success and failure judgments for measuring whether the loop improves. |
| Source evidence | Requests, sessions, interactions, and metadata that keep learning traceable. |
Data model at a glance
Interactions are the input. Profiles personalize responses. Playbooks improve behavior. Requests and sessions keep the loop inspectable.
Publish evidence, learn from it, retrieve what was learned, and augment the next prompt — every turn makes the agent better.