Playbook Management
Methods for reviewing, searching, retrieving, adding, and deleting user playbooks and agent playbooks.
search_user_playbooksmethodSearch for user playbooks using semantic/text search and advanced filtering.
response = client.search_user_playbooks( query="user satisfaction", user_id="user_123", request_id="request_123", session_id="session_123", agent_version="v2.1.0", source="api", tags=["support"], top_k=10)| Prop | Type |
|---|---|
query | string |
user_id | string |
request_id | string |
session_id | string |
agent_version | string |
playbook_name | string |
source | string |
start_time | datetime |
end_time | datetime |
status_filter | list[Status] |
tags | string[] |
top_k | integer |
threshold | float |
enable_reformulation | boolean |
search_mode | SearchMode |
Returns SearchUserPlaybookResponse — see Playbook Models.
review_user_playbooksmethodRe-run the evidence-grounded reviewer over the newest current user playbooks created in an inclusive time window. top_k is applied in newest-first order. For each selected playbook, the server loads the full interaction window recorded by its finalized playbook-extraction run, adds any extra cited interactions retained through consolidation, and restores request grouping. Historical review is therefore not limited by the playbook's smaller cited-evidence subset, the current extraction window size, or the current source filter. Only cited IDs are presented as candidate evidence; the remaining generation-window interactions provide chronology without becoming additional evidence.
The default report mode runs inline and returns decisions without changing storage, while simulating the same newest-first context transitions as apply mode. Because each selected playbook receives a fresh model review, the server automatically gives this endpoint its extended synchronous timeout. A playbook is reported as skip when its finalized generation-window provenance, validated evidence metadata, or a required interaction/request is unavailable, or when its ownership provenance does not match the requesting user; the run then continues. The automatic reviewer that runs immediately after generation separately uses that generation's configured extraction window.
report_only=False to apply the decisions. Apply mode is accepted and run in the background — the response returns immediately with a run_id and an empty results list, because a run makes one model call and one write per selected playbook. The run reviews newest-first and commits each completed decision before reviewing the next playbook: accepted rows stay current, rejected rows are archived, and an edit inserts the replacement as current while superseding its incumbent. A later failure stops the run but leaves earlier decisions committed. Applied edits are recorded on the replacement's lineage under the returned run_id.from datetime import UTC, datetime response = client.review_user_playbooks( start_time=datetime(2026, 7, 1, tzinfo=UTC), end_time=datetime(2026, 7, 28, tzinfo=UTC), top_k=50, report_only=True,) for result in response.results: print(result.user_playbook_id, result.decision, result.reason)| Prop | Type |
|---|---|
start_timerequired | datetime |
end_timerequired | datetime |
top_k | integer |
report_only | boolean |
See ReviewUserPlaybooksResponse in Playbook Models for result fields and decision details.
search_agent_playbooksmethodSearch for agent playbooks using semantic/text search and advanced filtering. The optional source filter matches provenance: an agent playbook is included when at least one linked source user playbook has that exact source.
response = client.search_agent_playbooks( query="concise responses", user_id="user_123", agent_version="v2.1.0", source="api", tags=["tone"], playbook_status_filter="approved")| Prop | Type |
|---|---|
query | string |
user_id | string |
agent_version | string |
playbook_name | string |
source | string |
start_time | datetime |
end_time | datetime |
status_filter | list[Status] |
tags | string[] |
playbook_status_filter | PlaybookStatus |
top_k | integer |
threshold | float |
enable_reformulation | boolean |
search_mode | SearchMode |
Returns SearchAgentPlaybookResponse — see Playbook Models.
get_user_playbooksmethodRetrieve user playbook rows containing agent guidance, including entries extracted from interactions and rows created by supported manual or playbook-optimizer workflows.
response = client.get_user_playbooks( limit=100, tags=["support"])| Prop | Type |
|---|---|
limit | integer |
user_playbook_id | integer |
user_id | string |
request_id | string |
query | string |
playbook_name | string |
agent_version | string |
start_time | datetime |
end_time | datetime |
status_filter | list[Status] |
tags | string[] |
Returns GetUserPlaybooksResponse — see Playbook Models.
add_user_playbookmethodAdd user playbook entries directly to storage.
response = client.add_user_playbook( user_playbooks=[ { "agent_version": "v2.1.0", "request_id": "req_123", "content": "User expressed satisfaction with response" } ])| Prop | Type |
|---|---|
user_playbooksrequired | list[UserPlaybook | dict] |
content or trigger must be provided.Returns AddUserPlaybookResponse — see Playbook Models.
add_agent_playbooksmethodAdd agent playbook entries directly to storage.
response = client.add_agent_playbooks( agent_playbooks=[ { "agent_version": "v2.1.0", "content": "Agent should provide more concise responses", "playbook_status": "approved", "playbook_metadata": "{}" } ])| Prop | Type |
|---|---|
agent_playbooksrequired | list[AgentPlaybook | dict] |
Returns AddAgentPlaybookResponse — see Playbook Models.
get_agent_playbooksmethodRetrieve agent playbook entries.
response = client.get_agent_playbooks( limit=10, tags=["tone"])| Prop | Type |
|---|---|
limit | integer |
agent_playbook_id | integer |
query | string |
playbook_name | string |
agent_version | string |
start_time | datetime |
end_time | datetime |
status_filter | list[Status] |
tags | string[] |
playbook_status_filter | PlaybookStatus |
force_refresh | boolean |
Returns GetAgentPlaybooksResponse — see Playbook Models. Cached for 10 minutes; pass force_refresh=True to bypass.
Update Methods
update_user_playbookmethodUpdate editable fields of a user playbook in place. Pass only the fields you want to change.
response = client.update_user_playbook( user_playbook_id=42, content="Refined playbook content",)| Prop | Type |
|---|---|
user_playbook_idrequired | integer |
playbook_name | string |
content | string |
trigger | string |
rationale | string |
Returns: UpdateUserPlaybookResponse with success and message.
update_agent_playbookmethodUpdate editable fields of an agent playbook in place. Pass only the fields you want to change.
response = client.update_agent_playbook( agent_playbook_id=17, content="Updated guidance")| Prop | Type |
|---|---|
agent_playbook_idrequired | integer |
playbook_name | string |
content | string |
trigger | string |
rationale | string |
playbook_status | PlaybookStatus |
Returns: UpdateAgentPlaybookResponse with success and message.
update_agent_playbook_statusmethodDedicated endpoint for the approval workflow (approve / pending / reject). Use this instead of update_agent_playbook when the only change is the playbook_status — the server enforces tighter validation and writes a smaller change log.
from emend import PlaybookStatus response = client.update_agent_playbook_status( agent_playbook_id=17, playbook_status=PlaybookStatus.APPROVED,)| Prop | Type |
|---|---|
agent_playbook_idrequired | integer |
playbook_statusrequired | PlaybookStatus |
Returns: UpdatePlaybookStatusResponse with success and message.
delete_agent_playbookmethodDelete an agent playbook by ID.
response = client.delete_agent_playbook( agent_playbook_id=123, wait_for_response=True)| Prop | Type |
|---|---|
agent_playbook_idrequired | integer |
wait_for_response | boolean |
delete_user_playbookmethodDelete a user playbook by ID.
response = client.delete_user_playbook( user_playbook_id=456, wait_for_response=True)| Prop | Type |
|---|---|
user_playbook_idrequired | integer |
wait_for_response | boolean |
Bulk Delete Operations
delete_agent_playbooks_by_idsmethodDelete multiple agent playbooks by their IDs.
response = client.delete_agent_playbooks_by_ids(agent_playbook_ids=[1, 2, 3])| Prop | Type |
|---|---|
agent_playbook_idsrequired | list[integer] |
Returns: BulkDeleteResponse with success, deleted_count, and message.
delete_user_playbooks_by_idsmethodDelete multiple user playbooks by their IDs.
response = client.delete_user_playbooks_by_ids(user_playbook_ids=[1, 2, 3])| Prop | Type |
|---|---|
user_playbook_idsrequired | list[integer] |
Returns: BulkDeleteResponse with success, deleted_count, and message.
delete_all_playbooksmethodDelete all playbooks (both user and agent). Cascading variant — wipes both stores.
response = client.delete_all_playbooks()Returns: BulkDeleteResponse with success, deleted_count, and message.
delete_all_user_playbooksmethodDelete all user playbooks (user only, not agent).
response = client.delete_all_user_playbooks()Returns: BulkDeleteResponse with success, deleted_count, and message.
delete_all_agent_playbooksmethodDelete all agent playbooks (agent only, not user).
response = client.delete_all_agent_playbooks()Returns: BulkDeleteResponse with success, deleted_count, and message.