Metadata-Version: 2.4
Name: redis-agent-playbook
Version: 0.1.0b2
Summary: Python Client SDK for Redis AgentPlaybooks
License: MIT
License-File: LICENSE
Author: Redis AI Services Team
Requires-Python: >=3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: httpcore (>=1.0.9)
Requires-Dist: httpx (>=0.28.1)
Requires-Dist: pydantic (>=2.11.2)
Project-URL: Documentation, https://pypi.org/project/redis-agent-playbook/
Project-URL: Homepage, https://redis.io/docs/latest/develop/ai/
Description-Content-Type: text/markdown

# redis-agent-playbook

Python SDK for Redis AgentPlaybooks: manage Playbooks and author, publish, and retrieve FAQs and Skills.

[![Built by Speakeasy](https://img.shields.io/badge/Built_by-SPEAKEASY-374151?style=for-the-badge&labelColor=f3f4f6)](https://www.speakeasy.com/?utm_source=redis-agent-playbook&utm_campaign=python)
[![License: MIT](https://img.shields.io/badge/LICENSE_//_MIT-3b5bdb?style=for-the-badge&labelColor=eff6ff)](https://opensource.org/licenses/MIT)

<!-- Start Summary [summary] -->
## Summary

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

For more information about the API: [Redis AI documentation](https://redis.io/docs/latest/develop/ai/)
<!-- End Summary [summary] -->

## Documentation

- [Redis AI documentation](https://redis.io/docs/latest/develop/ai/)
- [PyPI package page](https://pypi.org/project/redis-agent-playbook/)
- [SDK examples](#sdk-example-usage) show FAQ and Skill authoring, search,
  discovery, and proposal review.
- [Common workflows](#common-workflows) cover versioning, publication,
  pagination, and exact Skill resource verification.
- [Available methods](#available-resources-and-operations) list the data-plane API.

The examples and workflows on this page form the Playbook SDK guide. The Redis AI
documentation provides broader product context.

## Control and data plane clients

AgentPlaybooks is the product; a Playbook is one instance managed by a user or operator.

One installation of `redis-agent-playbook` provides two independently configured
clients. `AgentPlaybooksService` manages Playbook instances through the control-plane
API. `Playbook` operates on the content of one instance through the data-plane API.

```python
import os
from redis_agent_playbook import Playbook, AgentPlaybooksService

with AgentPlaybooksService(
    server_url=os.environ["AGENT_PLAYBOOKS_CONTROL_PLANE_URL"],
    token=os.environ["AGENT_PLAYBOOKS_SERVICE_TOKEN"],
) as service:
    instances = service.list_playbooks()
    instance = service.get_playbook(playbook_id=os.environ["AGENT_PLAYBOOKS_PLAYBOOK_ID"])

with Playbook(
    server_url=os.environ["AGENT_PLAYBOOKS_DATA_PLANE_URL"],
    api_key=os.environ["AGENT_PLAYBOOKS_API_KEY"],
    playbook_id=instance.playbook_id,
) as playbook:
    faqs = playbook.list_faqs()
    print(faqs)
```

Set these connection values before running the example:

| Variable | Value |
| --- | --- |
| `AGENT_PLAYBOOKS_CONTROL_PLANE_URL` | Your deployment's control-plane endpoint |
| `AGENT_PLAYBOOKS_DATA_PLANE_URL` | Its separate data-plane endpoint |
| `AGENT_PLAYBOOKS_SERVICE_TOKEN` | An authorized control-plane bearer token |
| `AGENT_PLAYBOOKS_API_KEY` | An agent key scoped to the selected Playbook |
| `AGENT_PLAYBOOKS_PLAYBOOK_ID` | The service-issued ID of that Playbook |
| `AGENT_PLAYBOOKS_DEBUG` | Enable data-plane HTTP debug logging |
| `AGENT_PLAYBOOKS_SERVICE_DEBUG` | Enable control-plane HTTP debug logging |

The SDKs automatically read the API key, Playbook ID, service token, and debug
settings when the corresponding constructor option is omitted. Explicit options
win, followed by `AGENT_PLAYBOOKS_*` variables, then legacy aliases:
`PLAYBOOK_API_KEY`, `PLAYBOOK_PLAYBOOK_ID`, `PLAYBOOK_DEBUG`,
`PLAYBOOK_SERVICE_TOKEN`, and `PLAYBOOK_SERVICE_DEBUG`. An explicitly set empty
new variable suppresses its legacy alias. These aliases do not modify the process
environment or allow credentials to cross between the two clients.

The URL variables above are application settings used by these examples. Both
clients require an explicit `server_url` (Python) or `serverURL` (TypeScript);
the core SDKs do not automatically read URLs from the environment.

Supply the appropriate URL and credential for each plane. The SDK does not
derive a data-plane URL or credential from a control-plane response. Control-plane
methods take `playbook_id` per call; the same service client can manage many
instances. Data-plane calls retain the existing instance-bound interface. Creating a
Playbook does not mint a data-plane key; obtain it through your deployment's
Identity Service. Wait for a newly provisioned Playbook to reach `ready` before
content operations.

Both clients support `timeout_ms`, `retry_config`, `debug_logger`, custom `client`
and `async_client` transports, and callable credential providers. Asynchronous
methods have an `_async` suffix and clients support `async with`. Supplied HTTP
clients remain caller-owned. Requests are not retried by default; configure
retries deliberately for operations which are safe to repeat.

If omitted, the CP credential is read from `AGENT_PLAYBOOKS_SERVICE_TOKEN`; it never
falls back to `AGENT_PLAYBOOKS_API_KEY`. The DP credential and resource binding use `AGENT_PLAYBOOKS_API_KEY` and
`AGENT_PLAYBOOKS_PLAYBOOK_ID` when omitted from the constructor.
CP models, exceptions and retry helpers live under
`redis_agent_playbook.controlplane.models`, `.errors` and `.utils`. Existing DP
imports remain unchanged. The CP resource model named `Playbook` lives in that
models namespace and does not replace the public DP client.

The control-plane client covers:

| Task | Methods |
| --- | --- |
| Provision and manage instances | `create_playbook`, `list_playbooks`, `get_playbook`, `update_playbook`, `delete_playbook` |
| Clear content administratively | `clear_playbook` (requires `product_admin` or `suite_admin`) |
| Manage extraction | `list_extraction_stores`, `list_extraction_bindings`, `create_extraction_binding`, `get_extraction_binding`, `update_extraction_binding`, `delete_extraction_binding` |
| Discover supported models | `list_models` |
| Discover cloud resources | `list_databases`, `get_network_info` |
| Manage cloud model credentials | `get_model_credential`, `put_model_credential`, `delete_model_credential` |

See the control-plane operation reference
for provisioning, policy updates, deletion, administrative clear, and extraction
binding operations. These methods also have generated asynchronous variants.

### Deployment availability

The shared control-plane operations work with both cloud and on-prem deployments.
`list_models` lists the deployment’s supported models, including the on-prem
embedding allowlist. `list_databases`, `get_network_info`, `get_model_credential`,
`put_model_credential`, and `delete_model_credential` (including their async
variants) are **cloud only**.
Their generated method documentation is labeled `Cloud only`.

The optional `llm` field on create/update and resource responses is also **cloud
only**. Omit it for on-prem requests; on-prem responses do not contain it. No
constructor deployment flag is required: configure the appropriate endpoint.
Credential reads return status only, never a provider API key. These provider
credentials are separate from the control-plane token and data-plane agent key.

Cloud resource management and database discovery require the cloud session
cookie (`JSESSIONID`) and CSRF header (`X-CSRF-Token`) in addition to the operator
token; supply these through the client’s HTTP transport. Cloud
responses expose typed endpoint accessibility, egress addresses, and database
network metadata. These optional fields may be absent on-prem.

### Extraction binding access and readiness

Store suggestions are scoped to the tenant and do not grant access. Creating a
binding synchronously checks the caller's management consent, same-account RAM
store ownership, destination readiness, and execution scope. A foreign or missing
source is refused without revealing its metadata.

A new binding returns `ready` with `enabled=false`. Enable it with an update that
passes its `version` as `expected_version`. Every explicit enable revalidates source
consent and ownership with the current caller and can recover a blocked binding.
Pausing or deleting requires destination management access and makes no source or
grant-administration request. Runtime failures can mark a binding `blocked`;
clients must tolerate unknown `blockedReason` values.

Scan cadence is deployment-owned worker configuration. Binding requests and
responses omit `intervalSeconds`; `idleWindowSeconds` remains user-configurable.

## Release status

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

```bash
pip install --pre redis-agent-playbook
```

The prepared release is `0.1.0b2` (`0.1.0-beta.2` in generator metadata).
After publication, pin it with `pip install redis-agent-playbook==0.1.0b2`.

Pin an exact published version in applications and upgrade intentionally.

## Upgrading to beta.2

Extraction job responses no longer expose `intervalSeconds`, and
`ExtractionBindingStatus` no longer declares `preparing`. Successful binding
creation returns `ready` and disabled; remove preparation polling and enable
explicitly after reviewing the binding. Remove reads of the retired scan-cadence
field and configure cadence on the deployment instead.

Cloud list/detail responses can report `state=unavailable` while preserving saved
configuration and omitting live database enrichment. This read state does not
confirm deletion or probe content Redis health. It cannot be submitted in a
mutation; writable states remain `ready` and `suspended`.

## Upgrading to beta.1

The control-plane client is now `AgentPlaybooksService`, replacing
`PlaybookService` without a compatibility alias. Update imports from both
`redis_agent_playbook` and `redis_agent_playbook.controlplane`. Its base error is
now `redis_agent_playbook.controlplane.errors.AgentPlaybooksServiceError`.
The data-plane client remains `Playbook`. Environment variables now use the
product prefix `AGENT_PLAYBOOKS`; the previous runtime names remain fallback
aliases as described above. Endpoints are unchanged. Both clients are regenerated from the same Iris main
revision recorded in the contract provenance.

## 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 data-plane 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.

<!-- Start Table of Contents [toc] -->
## Table of Contents
<!-- $toc-max-depth=2 -->
* [redis-agent-playbook](#redis-agent-playbook)
  * [Documentation](#documentation)
  * [Control and data plane clients](#control-and-data-plane-clients)
  * [Release status](#release-status)
  * [Upgrading to beta.2](#upgrading-to-beta2)
  * [Upgrading to beta.1](#upgrading-to-beta1)
  * [Upgrading from alpha.2](#upgrading-from-alpha2)
  * [SDK Installation](#sdk-installation)
  * [IDE Support](#ide-support)
  * [SDK Example Usage](#sdk-example-usage)
  * [Common workflows](#common-workflows)
  * [Authentication](#authentication)
  * [Available Resources and Operations](#available-resources-and-operations)
  * [Global Parameters](#global-parameters)
  * [Retries](#retries)
  * [Error Handling](#error-handling)
  * [Custom HTTP Client](#custom-http-client)
  * [Resource Management](#resource-management)
  * [Debugging](#debugging)
* [Development](#development)
  * [Maturity](#maturity)
  * [Contributions](#contributions)

<!-- End Table of Contents [toc] -->

## SDK Installation

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

```bash
pip install redis-agent-playbook==0.1.0b2
uv add redis-agent-playbook==0.1.0b2
poetry add redis-agent-playbook==0.1.0b2
```

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.
<!-- No SDK Installation [installation] -->

<!-- Start IDE Support [idesupport] -->
## 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.

- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
<!-- End IDE Support [idesupport] -->

<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage

### Create an FAQ

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

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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`.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


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

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

    # Handle response
    print(res)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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`.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# 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="<AGENT_PLAYBOOKS_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)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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.

```python
# Synchronous Example
from redis_agent_playbook import Playbook


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

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

    # Handle response
    print(res)
```

</br>

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

```python
# 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="<AGENT_PLAYBOOKS_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())
```
<!-- End SDK Example Usage [usage] -->

## 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.

```python
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="<AGENT_PLAYBOOKS_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.

```python
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="<AGENT_PLAYBOOKS_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.

```python
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="<AGENT_PLAYBOOKS_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.

```python
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="<AGENT_PLAYBOOKS_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.

<!-- Start Authentication [security] -->
## Authentication

### Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name      | Type | Scheme      | Environment Variable      |
| --------- | ---- | ----------- | ------------------------- |
| `api_key` | http | HTTP Bearer | `AGENT_PLAYBOOKS_API_KEY` |

To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
```python
from redis_agent_playbook import Playbook


with Playbook(
    "https://api.example.com",
    api_key="<AGENT_PLAYBOOKS_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)

```
<!-- End Authentication [security] -->

<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations

<details open>
<summary>Available methods</summary>

### 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.


</details>
<!-- End Available Resources and Operations [operations] -->

## Global Parameters

A client is bound to one Playbook. Set `playbook_id` in the constructor or set
`AGENT_PLAYBOOKS_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.

```python
from redis_agent_playbook import Playbook

with Playbook(
    "https://api.example.com",
    playbook_id="pb_0123456789abcdef0123456789abcdef",
    api_key="<AGENT_PLAYBOOKS_API_KEY>",
) as playbook:
    print(playbook.get_playbook_health())
```
<!-- No Global Parameters [global-parameters] -->

## 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.

```python
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="<AGENT_PLAYBOOKS_API_KEY>",
) as playbook:
    result = playbook.discover_entries(
        query="Where is my refund?",
        retries=RetryConfig("backoff", BackoffStrategy(100, 1000, 2, 5000), True),
    )
    print(result)
```
<!-- No Retries [retries] -->

<!-- Start Error Handling [errors] -->
## 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](#error-classes). |

### Example
```python
from redis_agent_playbook import Playbook, errors


with Playbook(
    "https://api.example.com",
    playbook_id="<id>",
    api_key="<AGENT_PLAYBOOKS_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`.

<details><summary>Less common errors (5)</summary>

<br />

**Network errors:**
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
    * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
    * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.


**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.

</details>
<!-- End Error Handling [errors] -->

## 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.

```python
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="<AGENT_PLAYBOOKS_API_KEY>",
        client=http_client,
    ) as playbook:
        print(playbook.get_playbook_health())
```
<!-- No Custom HTTP Client [http-client] -->

## 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:

```python
from redis_agent_playbook import Playbook

async def main():
    async with Playbook(
        "https://api.example.com",
        playbook_id="pb_0123456789abcdef0123456789abcdef",
        api_key="<AGENT_PLAYBOOKS_API_KEY>",
    ) as playbook:
        print(await playbook.get_playbook_health_async())
```
<!-- No Resource Management [resource-management] -->

<!-- Start Debugging [debug] -->
## 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.
```python
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 `AGENT_PLAYBOOKS_DEBUG` to true.
<!-- End Debugging [debug] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

# Development

## Maturity

This SDK is a beta 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 beta.

## 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](https://www.speakeasy.com/?utm_source=redis-agent-playbook&utm_campaign=python)

