Skip to content

Add intuitive resource APIs to MasonClient - #482

Open
annzhang-db wants to merge 10 commits into
databricks:mainfrom
annzhang-db:add-mason-sdk
Open

Add intuitive resource APIs to MasonClient#482
annzhang-db wants to merge 10 commits into
databricks:mainfrom
annzhang-db:add-mason-sdk

Conversation

@annzhang-db

@annzhang-db annzhang-db commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds a small resource-oriented Python SDK over the Mason APIs. It returns typed resource handles, automatically consumes paginated list results, and keeps updates and deletes on the resources they affect.

The public layer is intentionally separate from transport. It currently wraps the private _MasonApiClient; once the autogenerated API is available, that transport can be replaced by WorkspaceClient.mason without changing the resource-oriented surface below.

SDK shape

MasonClient
├── memory_stores.create(name) / get(id) / list()
│   └── MemoryStore
│       ├── add(...) / get(id) / list(...) / search(...)
│       └── update(...) / delete()
│           └── Memory.update(...) / delete()
└── session_stores.create(name) / get(name) / list()
    └── SessionStore
        ├── add(...) / get(id) / list(...)
        └── update(...) / delete()
            └── Session
                ├── append_items(...) / list_items(...)
                ├── pop_item() / clear_items() / fork(...)
                └── update(...) / delete()

Store collections use create() to create stores. Bound stores use add() for memories and sessions, leaving room for richer add semantics such as create-if-absent, append, or overwrite. IDs for memory_store.get(id) and session_store.get(id) are positional. The SDK does not implement a client-side get_or_create or non-atomic append_memory. Session deletion is non-cascading by default; pass force=True to recursively delete descendant sessions.

Examples

from databricks.sdk import WorkspaceClient
from databricks_mason import MasonClient

mason = MasonClient(WorkspaceClient(profile="my-workspace"))

memory_store = mason.memory_stores.create("coding-agent-memory")
memory = memory_store.add(
    actor_id="alice",
    path="/preferences/style.md",
    content="The user prefers concise answers.",
)
matches = memory_store.search(
    actor_id="alice",
    query="response preferences",
    limit=10,
)
memory = memory_store.get(memory.id)
memory = memory.update(content="The user prefers very concise answers.")
session_store = mason.session_stores.create("support-agent-sessions")
session = session_store.add(
    actor_id="customer-123",
    session_id="case-456",
)
session.append_items(
    [
        {"type": "message", "role": "user", "content": "I need help."},
        {"type": "message", "role": "assistant", "content": "Let's take a look."},
    ]
)
session = session_store.get("case-456")
items = list(session.list_items())

Validation

The Mason unit suite passes with 251 tests. Ruff lint/format and ty check also pass.

@annzhang-db
annzhang-db requested a review from smurching August 28, 2026 00:10

@smurching smurching left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annzhang-db thanks for adding this, how did you test it/did we do any validation to make sure the generated APIs are similar to what will eventually land in Databricks SDK?

@annzhang-db
annzhang-db force-pushed the add-mason-sdk branch 5 times, most recently from f3913c5 to ac17efc Compare September 1, 2026 18:05
@annzhang-db annzhang-db changed the title Add a typed, importable Python SDK to databricks-mason Add intuitive resource APIs to MasonClient Sep 1, 2026
@qinxinw-db

Copy link
Copy Markdown
Contributor

for operations on the MemoryStore entity, should we simplify it to:

memory_store.add() # would prefer add over create here as we can support different semantics: create if not exist, append, overwrite. 
memory_store.search()
memory_store.get()

etc. similar for session store.

annzhang-db and others added 10 commits September 2, 2026 21:46
Adds an ergonomic SDK layer (DatabricksAgentClient + typed resource handles)
over the existing AgentApiClient, alongside the CLI. It returns typed models
instead of raw dicts, auto-consumes pagination, and adds convenience lookups
(get-or-create memory stores, read-modify-write append). No existing modules
are changed except additive package exports.

Co-authored-by: Isaac <no-reply@databricks.com>

@qinxinw-db qinxinw-db left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api shape looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants