Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

redis-agent-playbook

Developer-friendly & type-safe Python SDK specifically catered to leverage redis-agent-playbook API.

Built by Speakeasy License: MIT

Summary

Redis Playbook: Public type-specific FAQ and Skill authoring, publication, and exact-version API.

For more information about the API: Redis AI documentation

Documentation

Dedicated Playbook product guides are required before a stable release. Until then, this alpha package and its generated reference are the SDK documentation.

Release status

This SDK is an alpha prerelease. Breaking changes may land between alpha releases without a major-version increment. Install prereleases explicitly:

pip install --pre redis-agent-playbook

The prepared release is 0.1.0a3 (0.1.0-alpha.3 in generator metadata). After publication, pin it with pip install redis-agent-playbook==0.1.0a3. Merge does not publish; both package releases require manual workflow dispatch.

Pin an exact published version in applications and upgrade intentionally.

Upgrading from alpha.2

Alpha.3 requires a server with the updated proposal contract. Publish both SDKs only after the corresponding data-plane rollout is ready. Acceptance returns a historical result.versionCreated receipt (Python: result.version_created) instead of top-level entry/version objects. It does not establish current target existence or publication; publishing remains a separate operation.

Remove evidence schemaVersion (Python: schema_version) and producer version. Producer name is required; optional promptVersion/prompt_version identifies the actual prompt set, and commitSHA/commit_sha accepts a full lowercase Git SHA-1 or SHA-256 revision. Omit unavailable metadata and retain the original observation timestamp for retries. Creation source is immutable and does not increment evidenceCount/evidence_count. Proposal list/search support action and entry type selectors. The public clear operation and its models have been removed; use explicit FAQ/Skill deletion operations when needed.

Proposal input content is distinct from normalized read content; only FAQ-add proposals are supported. Future response union members are retained in raw (Python: UnknownProposalMember; TypeScript: isUnknown: true). Inspect or upgrade before acting on an unknown response. Unknown members do not enable new writes. Proposal contentDigest/content_digest is optional in the general response contract for future actions without content.

Table of Contents

SDK Installation

Python 3.10 or later is required. After alpha.3 is published, install the exact prerelease with your package manager:

pip install redis-agent-playbook==0.1.0a3
uv add redis-agent-playbook==0.1.0a3
poetry add redis-agent-playbook==0.1.0a3

Supply your deployment URL, bearer token, and service-issued Playbook ID. <id> and <playbook-id> in generated examples are placeholders; they do not satisfy ^pb_[0-9a-f]{32}$ and must be replaced before running a snippet.

IDE Support

PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

SDK Example Usage

Create an FAQ

Create the first immutable version of a customer-support FAQ. The returned entry is an unpublished draft.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.create_faq(content={
        "intents": [
            "Where is my refund?",
            "Refund still processing",
        ],
        "attributes": {
            "audience": "support",
            "locale": "en-US",
            "topic": "refund",
        },
        "metadata": {
            "sourceId": "support-refund-policy-v4",
            "status": "approved",
        },
        "payload": {
            "faq": {
                "question": "How can support check the status of an in-flight refund?",
                "answer": "Look up the refund by order ID, share its current stage and date, and do not promise a bank posting date.",
            },
        },
    }, entry_key="refund-status-check")

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.create_faq_async(content={
            "intents": [
                "Where is my refund?",
                "Refund still processing",
            ],
            "attributes": {
                "audience": "support",
                "locale": "en-US",
                "topic": "refund",
            },
            "metadata": {
                "sourceId": "support-refund-policy-v4",
                "status": "approved",
            },
            "payload": {
                "faq": {
                    "question": "How can support check the status of an in-flight refund?",
                    "answer": "Look up the refund by order ID, share its current stage and date, and do not promise a bank posting date.",
                },
            },
        }, entry_key="refund-status-check")

        # Handle response
        print(res)

asyncio.run(main())

Add an FAQ version

Append an immutable version to an existing FAQ. Replace the example ID with the entry ID returned by create_faq.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.append_faq_version(faq_id="ent_0123456789abcdef0123456789abcdef", content={
        "intents": [
            "Where is my refund?",
            "Check refund progress",
        ],
        "attributes": {
            "audience": "support",
            "locale": "en-US",
            "topic": "refund",
        },
        "metadata": {
            "sourceId": "support-refund-policy-v5",
            "status": "approved",
        },
        "payload": {
            "faq": {
                "question": "How can support check the status of an in-flight refund?",
                "answer": "Look up the refund by order ID and share its current stage and date. Card refunds normally post 5 to 10 business days after warehouse receipt.",
            },
        },
    })

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.append_faq_version_async(faq_id="ent_0123456789abcdef0123456789abcdef", content={
            "intents": [
                "Where is my refund?",
                "Check refund progress",
            ],
            "attributes": {
                "audience": "support",
                "locale": "en-US",
                "topic": "refund",
            },
            "metadata": {
                "sourceId": "support-refund-policy-v5",
                "status": "approved",
            },
            "payload": {
                "faq": {
                    "question": "How can support check the status of an in-flight refund?",
                    "answer": "Look up the refund by order ID and share its current stage and date. Card refunds normally post 5 to 10 business days after warehouse receipt.",
                },
            },
        })

        # Handle response
        print(res)

asyncio.run(main())

Publish an FAQ version

Publish the selected immutable FAQ version so it can be returned by search and discovery.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.publish_faq(faq_id="ent_0123456789abcdef0123456789abcdef", version=2)

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.publish_faq_async(faq_id="ent_0123456789abcdef0123456789abcdef", version=2)

        # Handle response
        print(res)

asyncio.run(main())

Create a Skill

Create an unpublished Skill from a base64-encoded Agent Skills ZIP. Replace the package placeholder with an encoded archive rooted at late-delivery-resolution/ and containing SKILL.md.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.create_skill(package_base64="BASE64_ENCODED_AGENT_SKILL_ZIP", content={
        "intents": [
            "Resolve a late delivery",
            "Package has not arrived",
        ],
        "attributes": {
            "audience": "support",
            "locale": "en-US",
            "topic": "delivery",
        },
        "metadata": {
            "sourceId": "runbook-late-delivery-v1",
            "status": "approved",
        },
    }, entry_key="late-delivery-resolution")

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.create_skill_async(package_base64="BASE64_ENCODED_AGENT_SKILL_ZIP", content={
            "intents": [
                "Resolve a late delivery",
                "Package has not arrived",
            ],
            "attributes": {
                "audience": "support",
                "locale": "en-US",
                "topic": "delivery",
            },
            "metadata": {
                "sourceId": "runbook-late-delivery-v1",
                "status": "approved",
            },
        }, entry_key="late-delivery-resolution")

        # Handle response
        print(res)

asyncio.run(main())

Search FAQs

Search only published FAQs, restrict results to exact-match attributes, and override the similarity threshold for this request.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.search_faqs(query="Where is my refund?", filter_={
        "and_": [
            {
                "eq": {
                    "name": "audience",
                    "value": "support",
                },
            },
            {
                "eq": {
                    "name": "locale",
                    "value": "en-US",
                },
            },
        ],
    }, minimum_score=0.72, limit=5)

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.search_faqs_async(query="Where is my refund?", filter_={
            "and_": [
                {
                    "eq": {
                        "name": "audience",
                        "value": "support",
                    },
                },
                {
                    "eq": {
                        "name": "locale",
                        "value": "en-US",
                    },
                },
            ],
        }, minimum_score=0.72, limit=5)

        # Handle response
        print(res)

asyncio.run(main())

Search Skills

Search only published Skills. Skill matches contain compact previews with canonical exact-version SKILL.md URIs.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.search_skills(query="How should I resolve a delayed delivery?", filter_={
        "eq": {
            "name": "audience",
            "value": "support",
        },
    }, minimum_score=0.72, limit=5)

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.search_skills_async(query="How should I resolve a delayed delivery?", filter_={
            "eq": {
                "name": "audience",
                "value": "support",
            },
        }, minimum_score=0.72, limit=5)

        # Handle response
        print(res)

asyncio.run(main())

Discover Playbook entries

Search published FAQs and Skills together while pinning a known Skill by its immutable entry key. Pins are returned separately from semantic matches.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.discover_entries(query="A customer's order is late and they want a refund", filter_={
        "eq": {
            "name": "audience",
            "value": "support",
        },
    }, limit=10, pinned_entries=[
        {
            "entry_key": "late-delivery-resolution",
        },
    ])

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.discover_entries_async(query="A customer's order is late and they want a refund", filter_={
            "eq": {
                "name": "audience",
                "value": "support",
            },
        }, limit=10, pinned_entries=[
            {
                "entry_key": "late-delivery-resolution",
            },
        ])

        # Handle response
        print(res)

asyncio.run(main())

Create a proposal

Propose a new FAQ for review. Launch proposal authoring supports new FAQ entries.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.create_proposal(action={
        "add": {
            "target": {
                "new_entry": {
                    "entry_key": "refund-bank-delay",
                },
            },
            "candidate": {
                "content": {
                    "intents": [
                        "My refund has not appeared",
                    ],
                    "attributes": {
                        "audience": "support",
                        "locale": "en-US",
                        "topic": "refund",
                    },
                    "metadata": {
                        "sourceId": "support-refund-policy-v5",
                        "status": "proposed",
                    },
                    "payload": {
                        "faq": {
                            "question": "What should support say when a settled refund has not appeared?",
                            "answer": "Confirm the settlement date and explain that the issuing bank controls final posting time.",
                        },
                    },
                },
            },
        },
    })

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.create_proposal_async(action={
            "add": {
                "target": {
                    "new_entry": {
                        "entry_key": "refund-bank-delay",
                    },
                },
                "candidate": {
                    "content": {
                        "intents": [
                            "My refund has not appeared",
                        ],
                        "attributes": {
                            "audience": "support",
                            "locale": "en-US",
                            "topic": "refund",
                        },
                        "metadata": {
                            "sourceId": "support-refund-policy-v5",
                            "status": "proposed",
                        },
                        "payload": {
                            "faq": {
                                "question": "What should support say when a settled refund has not appeared?",
                                "answer": "Confirm the settlement date and explain that the issuing bank controls final posting time.",
                            },
                        },
                    },
                },
            },
        })

        # Handle response
        print(res)

asyncio.run(main())

Submit proposal evidence

Attach immutable source context to an open proposal. Reuse the same evidence ID and payload when retrying; evidence is retained on the proposal and is not copied to the accepted FAQ.

# Synchronous Example
from redis_agent_playbook import Playbook
from redis_agent_playbook.utils import parse_datetime


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.submit_proposal_evidence(proposal_id="prp_0123456789abcdef0123456789abcdef", evidence_id="evd_0123456789abcdef0123456789abcdef", observed_at=parse_datetime("2026-09-29T16:00:00Z"), producer={
        "name": "support-review",
        "prompt_version": "support-review-v1",
    }, source={
        "type": "document",
        "reference": {
            "documentId": "support-refund-policy-v5",
        },
        "content": {
            "excerpt": "The issuing bank controls final refund posting time.",
        },
    })

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook
from redis_agent_playbook.utils import parse_datetime

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.submit_proposal_evidence_async(proposal_id="prp_0123456789abcdef0123456789abcdef", evidence_id="evd_0123456789abcdef0123456789abcdef", observed_at=parse_datetime("2026-09-29T16:00:00Z"), producer={
            "name": "support-review",
            "prompt_version": "support-review-v1",
        }, source={
            "type": "document",
            "reference": {
                "documentId": "support-refund-policy-v5",
            },
            "content": {
                "excerpt": "The issuing bank controls final refund posting time.",
            },
        })

        # Handle response
        print(res)

asyncio.run(main())

Accept a proposal

Promote the reviewed revision to one canonical unpublished FAQ. Concurrent calls and retries resume or return the recorded target.

# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:

    res = playbook.accept_proposal(proposal_id="prp_0123456789abcdef0123456789abcdef", expected_proposal_revision=1)

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from redis_agent_playbook import Playbook

async def main():

    async with Playbook(
        "https://api.example.com",
        playbook_id="<id>",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:

        res = await playbook.accept_proposal_async(proposal_id="prp_0123456789abcdef0123456789abcdef", expected_proposal_revision=1)

        # Handle response
        print(res)

asyncio.run(main())

Common workflows

Playbook stores two entry types: FAQs and Skills. Creating or appending content produces an immutable version; publishing selects which version is available to search and discovery. Management reads can still retrieve unpublished entries and exact historical versions.

The examples below use fictional Northstar customer-support content. They are maintained outside the generated section above so they can show IDs and version numbers flowing between multiple SDK calls.

Create, version, publish, and read an FAQ

create_faq returns both the stable entry and version 1. Append creates another immutable version; it does not publish it automatically.

from redis_agent_playbook import Playbook


faq_v1 = {
    "intents": ["Where is my refund?", "Refund still processing"],
    "attributes": {
        "audience": "support",
        "locale": "en-US",
        "topic": "refund",
    },
    "metadata": {"sourceId": "support-refund-policy-v4", "status": "approved"},
    "payload": {
        "faq": {
            "question": "How can support check an in-flight refund?",
            "answer": "Look up the refund by order ID and share its stage and date.",
        }
    },
}

with Playbook(
    "https://api.example.com",
    playbook_id="<playbook-id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    created = playbook.create_faq(
        entry_key="refund-status-check",
        content=faq_v1,
    )
    faq_id = created.entry.entry_id

    appended = playbook.append_faq_version(
        faq_id=faq_id,
        content={
            **faq_v1,
            "metadata": {
                "sourceId": "support-refund-policy-v5",
                "status": "approved",
            },
            "payload": {
                "faq": {
                    "question": "How can support check an in-flight refund?",
                    "answer": (
                        "Share the current stage and date. Card refunds normally "
                        "post 5 to 10 business days after warehouse receipt."
                    ),
                }
            },
        },
    )

    playbook.publish_faq(
        faq_id=faq_id,
        version=appended.version.version,
    )

    entry = playbook.get_faq(faq_id=faq_id)
    exact_version = playbook.get_faq_version(
        faq_id=faq_id,
        version=appended.version.version,
    )
    entries = playbook.list_faqs(published=True, limit=20)
    versions = playbook.list_faq_versions(faq_id=faq_id, limit=20)

    print(entry.publication.version)
    print(exact_version.content.payload.faq.answer)
    print([item.entry_key for item in entries.faqs])
    print([item.version for item in versions.versions])

Continue a list request with its next_cursor until that field is absent. List results are not a global snapshot, so concurrent writes can move entries between pages.

Create and version a Skill

An Agent Skills package is a ZIP rooted at the Skill name and containing SKILL.md, for example late-delivery-resolution/SKILL.md. Encode the complete ZIP as base64; do not base64-encode the individual files.

import base64
from pathlib import Path

from redis_agent_playbook import Playbook


def encode_skill(path: str) -> str:
    return base64.b64encode(Path(path).read_bytes()).decode("ascii")


with Playbook(
    "https://api.example.com",
    playbook_id="<playbook-id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    created = playbook.create_skill(
        entry_key="late-delivery-resolution",
        package_base64=encode_skill("late-delivery-resolution-v1.zip"),
        content={
            "intents": ["Resolve a late delivery", "Package has not arrived"],
            "attributes": {
                "audience": "support",
                "locale": "en-US",
                "topic": "delivery",
            },
            "metadata": {
                "sourceId": "runbook-late-delivery-v1",
                "status": "approved",
            },
        },
    )
    skill_id = created.entry.entry_id

    appended = playbook.append_skill_version(
        skill_id=skill_id,
        package_base64=encode_skill("late-delivery-resolution-v2.zip"),
        content={
            "intents": ["Resolve a late delivery", "Escalate conflicting tracking"],
            "attributes": {
                "audience": "support",
                "locale": "en-US",
                "topic": "delivery",
            },
            "metadata": {
                "sourceId": "runbook-late-delivery-v2",
                "status": "approved",
            },
        },
    )
    playbook.publish_skill(
        skill_id=skill_id,
        version=appended.version.version,
    )

    entry = playbook.get_skill(skill_id=skill_id)
    exact_version = playbook.get_skill_version(
        skill_id=skill_id,
        version=appended.version.version,
    )
    entries = playbook.list_skills(published=True, limit=20)
    versions = playbook.list_skill_versions(skill_id=skill_id, limit=20)

    print(entry.publication.version)
    print(exact_version.content.payload.skill.manifest.name)
    print([item.entry_key for item in entries.skills])
    print([item.version for item in versions.versions])

Search FAQs, search Skills, and discover across both

Type-specific search returns only published entries of that type. Discovery searches published FAQs and Skills together. Filters match authored attributes exactly; metadata is returned to callers but is not the filter namespace. Null-valued equality filters return a validation error from the service.

from redis_agent_playbook import Playbook


support_filter = {
    "and_": [
        {"eq": {"name": "audience", "value": "support"}},
        {"eq": {"name": "locale", "value": "en-US"}},
    ]
}

with Playbook(
    "https://api.example.com",
    playbook_id="<playbook-id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    faq_results = playbook.search_faqs(
        query="Where is my refund?",
        filter_=support_filter,
        minimum_score=0.72,
        limit=5,
    )
    skill_results = playbook.search_skills(
        query="How should I resolve a delayed delivery?",
        filter_=support_filter,
        minimum_score=0.72,
        limit=5,
    )

    # Use the Playbook policy defaults for ranking, thresholds, and result count.
    default_discovery = playbook.discover_entries(
        query="A customer's order is late and they want a refund",
    )

    # Override this request and guarantee that a known Skill is supplied to the caller.
    guided_discovery = playbook.discover_entries(
        query="A customer's order is late and they want a refund",
        filter_=support_filter,
        limit=10,
        pinned_entries=[{"entry_key": "late-delivery-resolution"}],
    )

    print([match.faq.question for match in faq_results.matches])
    print([match.skill.name for match in skill_results.matches])
    print(default_discovery.discovered_entries)
    print(guided_discovery.pinned_entries)

Pinned entries are resolved separately from semantic matches. Check truncated when more eligible candidates existed than result slots, and budget_truncated when the Playbook token budget prevented an otherwise eligible entry from being returned.

Manage and accept proposals

New proposals start with zero attached evidence, even when creation source is supplied. Creation source is immutable and separate from evidence. Attach further source context with submit_proposal_evidence; proposal details expose evidence and evidence_count, while list/search previews expose evidence_count. Evidence is caller-supplied review context, not verified attribution, and is not copied to an accepted FAQ.

Proposal replacement uses optimistic concurrency. Read proposal_revision, review the complete candidate, and pass that revision to replace_proposal or accept_proposal. A conflict means another writer changed the proposal and the caller should fetch it again before deciding what to do.

from datetime import datetime, timezone
from uuid import uuid4

from redis_agent_playbook import Playbook, models


def proposed_faq(answer: str) -> dict:
    return {
        "add": {
            "target": {"new_entry": {"entry_key": "refund-bank-delay"}},
            "candidate": {
                "content": {
                    "intents": ["My refund has not appeared"],
                    "attributes": {
                        "audience": "support",
                        "locale": "en-US",
                        "topic": "refund",
                    },
                    "metadata": {
                        "sourceId": "support-refund-policy-v5",
                        "status": "proposed",
                    },
                    "payload": {
                        "faq": {
                            "question": (
                                "What should support say when a settled refund "
                                "has not appeared?"
                            ),
                            "answer": answer,
                        }
                    },
                }
            },
        }
    }


with Playbook(
    "https://api.example.com",
    playbook_id="<playbook-id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    created = playbook.create_proposal(
        action=proposed_faq("Explain that the issuing bank controls posting time."),
        source={"type": "document", "reference": {"documentId": "support-refund-policy-v5"}},
    )
    proposal_id = created.proposal_id

    # Save this ID and payload together; reuse both unchanged on a retry.
    evidence_id = "evd_" + uuid4().hex
    observed_at = datetime.now(timezone.utc)
    evidence_result = playbook.submit_proposal_evidence(
        proposal_id=proposal_id,
        evidence_id=evidence_id,
        observed_at=observed_at,
        producer={"name": "support-review", "prompt_version": "support-review-v1"},
        source={
            "type": "document",
            "reference": {"documentId": "support-refund-policy-v5"},
            "content": {
                "excerpt": "The issuing bank controls final refund posting time."
            },
        },
    )
    print(evidence_result.disposition, evidence_result.evidence_count)

    inbox = playbook.list_proposals(view=models.ProposalView.INBOX, limit=20)
    matches = playbook.search_proposals(
        query="refund posting delay", entry_type=models.EntryType.FAQ,
        action_type=models.ProposalActionType.ADD, limit=5,
    )
    reviewed = playbook.get_proposal(proposal_id=proposal_id)

    replaced = playbook.replace_proposal(
        proposal_id=proposal_id,
        expected_proposal_revision=reviewed.proposal_revision,
        action=proposed_faq(
            "Confirm the settlement date and explain that the issuing bank "
            "controls final posting time."
        ),
    )

    # Dismissal and restoration move a proposal between inbox and trash.
    dismissed = playbook.dismiss_proposal(
        proposal_id=proposal_id,
        expected_proposal_revision=replaced.proposal_revision,
    )
    restored = playbook.restore_proposal(proposal_id=proposal_id)

    # Acceptance promotes the reviewed revision to one canonical unpublished FAQ.
    accepted = playbook.accept_proposal(
        proposal_id=proposal_id,
        expected_proposal_revision=restored.proposal_revision,
    )
    if not isinstance(accepted.result, models.VersionCreated):
        raise ValueError("Review the unrecognized acceptance result before publishing")
    playbook.publish_faq(
        faq_id=accepted.result.version_created.entry_id,
        version=accepted.result.version_created.version,
    )

    print(len(inbox.proposals), len(matches.matches))

    # Purge is the permanent-delete operation. Use it only when the proposal
    # record is no longer required; it does not delete an FAQ already accepted.
    playbook.purge_proposal(proposal_id=proposal_id)

Proposal acceptance records one canonical target and is safe to retry with bounded backoff. Concurrent calls and retries resume the same promotion or return its recorded result.version_created receipt. This is historical completion evidence, independent of the target’s current existence or publication; publish that returned version separately when it is ready for serving.

Evidence IDs use evd_ followed by 32 lowercase hexadecimal characters. An exact ID/payload retry returns alreadyPresent; changing the payload under the same ID returns /errors/proposal-evidence-conflict. Each proposal can retain at most 100 records, subject to byte limits; capacity failures return /errors/proposal-evidence-capacity. When supplied, source.reference and source.content must be JSON objects. Their contents are opaque to Playbook.

Upgrading from alpha.1: remove support_id from create_proposal, replace add_proposal_support with submit_proposal_evidence, and replace support_count with evidence_count (including the ProposalSort member). Evidence submission requires the observation time, producer, and source in addition to its ID.

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
api_key http HTTP Bearer PLAYBOOK_API_KEY

To authenticate with the API the api_key parameter must be set when initializing the SDK client instance. For example:

from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    api_key="<PLAYBOOK_API_KEY>",
    playbook_id="<id>",
) as playbook:

    res = playbook.discover_entries(query="A customer's order is late and they want a refund", filter_={
        "eq": {
            "name": "audience",
            "value": "support",
        },
    }, limit=10, pinned_entries=[
        {
            "entry_key": "late-delivery-resolution",
        },
    ])

    # Handle response
    print(res)

Available Resources and Operations

Available methods

Playbook SDK

  • discover_entries
  • lookup_entries - Resolves bounded entry references to compact management state. Results preserve input order and report misses explicitly. Each item is authoritative when read, but the batch is not a global snapshot.
  • delete_faqs - Deletes the requested FAQ families sequentially. Each family deletion is atomic, but the batch is not: deletions completed before an error remain applied. Retrying the same request is safe because already absent entries are ignored.
  • list_faqs
  • create_faq
  • search_faqs
  • delete_faq
  • get_faq
  • withdraw_faq - Withdraws the FAQ publication without changing version content. An already-unpublished entry is a no-op. Concurrent publication changes are last-write-wins in Playbook v1.
  • publish_faq - Publishes the selected immutable FAQ version. Repeating the currently published version is a no-op. Concurrent publication changes are last-write-wins in Playbook v1.
  • list_faq_versions
  • append_faq_version
  • get_faq_version
  • get_playbook_health
  • list_proposals
  • create_proposal
  • search_proposals
  • purge_proposal
  • get_proposal
  • replace_proposal
  • accept_proposal - Promotes the reviewed revision to one canonical unpublished FAQ. Concurrent calls and retries resume or return the proposal's recorded target. A complete target may be visible to management before the proposal reaches promoted, but remains absent from serving until separately published.
  • restore_proposal
  • dismiss_proposal
  • submit_proposal_evidence
  • delete_skills - Deletes the requested Skill families sequentially. Each family deletion is atomic, but the batch is not: deletions completed before an error remain applied. Retrying the same request is safe because already absent entries are ignored.
  • list_skills
  • create_skill
  • search_skills
  • delete_skill
  • get_skill
  • withdraw_skill - Withdraws the Skill publication without changing version content. An already-unpublished entry is a no-op. Concurrent publication changes are last-write-wins in Playbook v1.
  • publish_skill - Publishes the selected immutable Skill version. Repeating the currently published version is a no-op. Concurrent publication changes are last-write-wins in Playbook v1.
  • list_skill_versions
  • append_skill_version
  • get_skill_version
  • get_skill_resource - Returns the exact immutable Skill resource bytes as a streamed response.

Every successful resource read includes a required Content-Digest response header. Header names are case-insensitive. The header uses the RFC 9530 sha-256=:<base64>: representation, while the resource descriptor in the Skill version uses sha256:<lowercase-hex>. Both encode the same SHA-256 digest bytes and must not be compared as strings.

Global Parameters

A client is bound to one Playbook. Set playbook_id in the constructor or set PLAYBOOK_PLAYBOOK_ID; the constructor option takes precedence. Methods do not expose a per-operation playbook_id override. Create another client for a different Playbook and supply server_url explicitly.

from redis_agent_playbook import Playbook

with Playbook(
    "https://api.example.com",
    playbook_id="pb_0123456789abcdef0123456789abcdef",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    print(playbook.get_playbook_health())

Retries

The client makes one attempt by default. Configure retry_config on the client or pass the keyword argument retries to an operation. Operation settings take precedence; backoff intervals are in milliseconds. Retry only when repeating the operation is safe for your workflow. Evidence retries must reuse the same stored ID, observation timestamp, and payload. An uncertain create or append response may already have written a logical record or version.

from redis_agent_playbook import Playbook
from redis_agent_playbook.utils import BackoffStrategy, RetryConfig

with Playbook(
    "https://api.example.com",
    playbook_id="pb_0123456789abcdef0123456789abcdef",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    result = playbook.discover_entries(
        query="Where is my refund?",
        retries=RetryConfig("backoff", BackoffStrategy(100, 1000, 2, 5000), True),
    )
    print(result)

Error Handling

PlaybookError is the base class for all HTTP error responses. It has the following properties:

Property Type Description
err.message str Error message
err.status_code int HTTP response status code eg 404
err.headers httpx.Headers HTTP response headers
err.body str HTTP body. Can be empty string if no body is returned.
err.raw_response httpx.Response Raw HTTP response
err.data Optional. Some errors may contain structured data. See Error Classes.

Example

from redis_agent_playbook import Playbook, errors


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<PLAYBOOK_API_KEY>",
) as playbook:
    res = None
    try:

        res = playbook.discover_entries(query="A customer's order is late and they want a refund", filter_={
            "eq": {
                "name": "audience",
                "value": "support",
            },
        }, limit=10, pinned_entries=[
            {
                "entry_key": "late-delivery-resolution",
            },
        ])

        # Handle response
        print(res)


    except errors.PlaybookError as e:
        # The base class for HTTP error responses
        print(e.message)
        print(e.status_code)
        print(e.body)
        print(e.headers)
        print(e.raw_response)

        # Depending on the method different errors may be thrown
        if isinstance(e, errors.RequestValidationErrorResponseContent):
            print(e.data.title)  # str
            print(e.data.status)  # Optional[int]
            print(e.data.detail)  # Optional[str]
            print(e.data.instance)  # Optional[str]
            print(e.data.type)  # models.RequestValidationErrorType

Error Classes

Primary errors:

  • PlaybookError: The base class for HTTP error responses.
    • RequestValidationErrorResponseContent: One HTTP 400 schema preserves every validation problem type in generated clients. Status code 400.
    • AuthenticationErrorResponseContent: Authentication credentials are missing, malformed, or invalid. Status code 401.
    • ForbiddenErrorResponseContent: The caller is authenticated but not allowed to access the requested resource. Status code 403.
    • NotFoundErrorResponseContent: The requested resource does not exist. Status code 404.
    • TimeoutErrorResponseContent: The request timed out before the service could complete it. Status code 408.
    • PlaybookConflictErrorResponseContent: One schema per HTTP status preserves the complete problem catalog in generated clients, following the Iris/Agent Memory dedicated error-type enum pattern. Status code 409.
    • PayloadTooLargeErrorResponseContent: The request payload exceeds the maximum supported size. Status code 413.
    • ResourceSuspendedErrorResponseContent: The requested resource exists but is suspended by an administrator. Status code 423.
    • FailedDependencyErrorResponseContent: A dependent resource required to process the request is unavailable or unhealthy. Status code 424.
    • TooManyRequestsErrorResponseContent: The service rejected the request because rate limits were exceeded. Status code 429.
    • PlaybookInternalErrorResponseContent: Stored integrity failures require operator investigation; editing or blindly retrying the request does not repair the stored record. Status code 500.
    • PlaybookServiceUnavailableErrorResponseContent: Retry reads and proposal acceptance with bounded backoff. Acceptance resumes its recorded canonical target. An uncertain create or append response may have written another logical record or version and should not be blindly retried when the caller requires exactly one result. Status code 503.
Less common errors (5)

Network errors:

Inherit from PlaybookError:

  • ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the cause attribute.

Custom HTTP Client

Pass client=httpx.Client(...) for synchronous calls or async_client=httpx.AsyncClient(...) for asynchronous calls. Both modes require an explicit deployment URL. Reuse a client for pooling and close it when finished.

import httpx
from redis_agent_playbook import Playbook

with httpx.Client(headers={"x-custom-header": "someValue"}) as http_client:
    with Playbook(
        "https://api.example.com",
        playbook_id="pb_0123456789abcdef0123456789abcdef",
        api_key="<PLAYBOOK_API_KEY>",
        client=http_client,
    ) as playbook:
        print(playbook.get_playbook_health())

Resource Management

Reuse a Playbook instance across calls. Context managers close the SDK's underlying HTTP clients. Asynchronous applications can use the async context manager and _async methods:

from redis_agent_playbook import Playbook

async def main():
    async with Playbook(
        "https://api.example.com",
        playbook_id="pb_0123456789abcdef0123456789abcdef",
        api_key="<PLAYBOOK_API_KEY>",
    ) as playbook:
        print(await playbook.get_playbook_health_async())

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass your own logger class directly into your SDK.

from redis_agent_playbook import Playbook
import logging

logging.basicConfig(level=logging.DEBUG)
s = Playbook(server_url="https://example.com", debug_logger=logging.getLogger("redis_agent_playbook"))

You can also enable a default debug logger by setting an environment variable PLAYBOOK_DEBUG to true.

Development

Maturity

This SDK is an alpha prerelease. Breaking changes may occur between prerelease versions without a major-version increment. Pin an exact package version so upgrades are intentional, and use prerelease installation flags when resolving the latest alpha.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

Metadata

Release files for redis-agent-playbook 0.1.0a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redis-agent-playbook 0.1.0a3
File Size Uploaded
redis_agent_playbook-0.1.0a3.tar.gz 103.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redis-agent-playbook 0.1.0a3
File Interpreter ABI Platform
redis_agent_playbook-0.1.0a3-py3-none-any.whl Python 3 none any Details

Total release size: 321.8 kB

Release files / redis_agent_playbook-0.1.0a3.tar.gz

Download URL redis_agent_playbook-0.1.0a3.tar.gz
Size 103.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c4e6a904e8fb4c53ce522c11251321a000561e682f24ae00333e3bda372da54d
BLAKE2b-256 checksum
How to use checksums
1e46b2283fc352bd501e1e16102249a070824171bae7b6c0e8780f99945029db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.22 Linux/6.8.0-1064-azure

Release files / redis_agent_playbook-0.1.0a3-py3-none-any.whl

Download URL redis_agent_playbook-0.1.0a3-py3-none-any.whl
Size 218.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1398e2ecaf75a7622b4516c79e0195f6374f98a0f361dc4c5ef24c11a37d84d
BLAKE2b-256 checksum
How to use checksums
b7b1edf4a38556389e3ae9a8dc694396943455ba26ed17bfd4f13a15098b9068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.22 Linux/6.8.0-1064-azure
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page