Publishing Interactions
Publish complete agent turns, feedback, images, actions, and expert examples.
Publish a completed agent turn after the response and any immediate user feedback are available. The same method works for Hosted Enterprise and Local OSS; only client initialization differs.
Recommended Pattern
from emend import InteractionData, EmendClient, UserActionType client = EmendClient() result = client.publish_interaction( user_id="user_123", session_id="support_2026_07_12_001", source="support-agent:v2", agent_version="support-agent@2.4.0", interactions=[ InteractionData( role="User", content="Please keep the answer under five steps.", user_action=UserActionType.NONE, ), InteractionData( role="Agent", content="Here is a concise four-step recovery plan...", user_action=UserActionType.NONE, retrieved_learnings=[ {"kind": "profile", "learning_id": "prof-abc123"}, {"kind": "user_playbook", "learning_id": "42"}, ], ), InteractionData( role="User", content="Perfect—this is the right level of detail.", user_action=UserActionType.NONE, ), ],) print(result.request_id, result.learning_status)Use the same session_id for related turns. Use a stable source for a product surface or traffic cohort, and set agent_version whenever you compare or aggregate agent behavior.
kind and learning_id on that response—even if you cannot tell whether each one changed the answer. This unlocks per-learning relevance and impact analysis for evaluated sessions and gives Emend attribution data for future optimization of retrieved learnings. Omit retrieved_learnings only when no Emend context was injected. Build the list from the same retained search results used in the prompt, not discarded candidates or only citations. See the complete search and publish example and grade-and-read workflow.get_learning_status(result.request_id) only when your workflow must observe completion. Use force_extraction=True and wait_for_response=True for deterministic tests and first-run demos, not the normal request path.Images and Screenshots
Set image_encoding to base64 image data when the visual content itself is evidence. Use interacted_image_url when a URL is enough to identify what the user saw. Include a short text description so the record remains understandable in logs and portal views.
InteractionData( role="User", content="The save button overlaps the footer on mobile.", image_encoding=base64_screenshot, interacted_image_url="https://app.example.com/settings",)Expert Examples
Use expert content when you have an ideal response that should teach a better procedure.
InteractionData( role="Agent", content=agent_response, expert_content="Verify account ownership before changing the billing email.",)Expert content is training evidence, not another conversational turn.
User Actions
Actions such as clicks, purchases, and cancellations can supply outcome evidence even when the user writes nothing.
InteractionData( role="User", content="", user_action=UserActionType.CLICK, user_action_description="Clicked Confirm cancellation",)Choose the Right Follow-up
- To retrieve learned context, see Searching Learned Context.
- To understand grouping, see Requests and Sessions.
- For evaluation-only and shadow traffic, see Evaluating Agent Performance.
- For every payload field and method option, see the Interaction API Reference.