Reflexio Documentation
Connect Reflexio to your agent, publish interactions, retrieve learned context, and inspect the learning loop.
reflexio-ai, start the backend, and publish locally.BuildConfigure learningModels, extractors, playbooks, evaluation, and storage.BuildPublish interactionsText, image, expert, session, and metadata patterns.ReferenceLook up methods and schemasPython 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 Reflexio can update what it knows.
from reflexio import ReflexioClient, InteractionData, UserActionType
client = ReflexioClient() # reads REFLEXIO_API_KEY
user_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": profile.profile_id}
for profile in context.profiles
),
*(
{"kind": "user_playbook", "learning_id": str(playbook.user_playbook_id)}
for playbook in context.user_playbooks
),
*(
{"kind": "agent_playbook", "learning_id": str(playbook.agent_playbook_id)}
for playbook 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,
)curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/search" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data '{"query":"Recommend a laptop for me.","user_id":"user_123","session_id":"session_001","agent_version":"support-agent@2","top_k":5,"entity_types":["profiles","user_playbooks","agent_playbooks"],"agent_playbook_status_filter":["approved"]}'
curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/publish_interaction" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"user_id": "user_123",
"session_id": "session_001",
"source": "support-agent:v2",
"agent_version": "support-agent@2",
"interaction_data_list": [
{"role": "User", "content": "Recommend a laptop for me."},
{
"role": "Agent",
"content": "The completed agent response.",
"retrieved_learnings": [
{"kind": "profile", "learning_id": "<profile_id returned by search>"},
{"kind": "user_playbook", "learning_id": "<user_playbook_id returned by search>"},
{"kind": "agent_playbook", "learning_id": "<agent_playbook_id returned by search>"}
]
}
]
}
JSONPublish every profile or playbook included in the model prompt using its returned stable ID, whether or not it influenced the answer. The Python example injects all search results; if you filter or truncate them, build both the prompt and retrieved_learnings from the same retained subset. Omit retrieved_learnings only when no Reflexio context was injected. Then grade the session and inspect relevance, impact, and judge reasons; the Evaluation dashboard shows quality and coverage across responses.
What Reflexio produces
Data model at a glance
Interactions are the input. Profiles personalize responses. Playbooks improve behavior. Requests and sessions keep the loop inspectable.
RequestAgent version, source, and sessionSessionConversation thread and user identityInteractionsUser turns, agent turns, feedback, and expert examples
async learning pipeline- User profilesPer-user preferences, goals, constraints, and memory
- User/Agent playbooksReusable behavior rules distilled from corrections
- Evaluation signalsOutcomes, shadow comparisons, and impact
search(query, user_id)One semantic call across learned contextcontext.profiles / context.agent_playbooksRanked artifacts for this turn
publish_interaction() as new evidence for step 1.