Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/oss/deepagents/async-subagents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ Async subagents let a supervisor agent launch background tasks that return immed

This builds on [subagents](/oss/deepagents/subagents), which run synchronously and block the supervisor until completion. Use async subagents when tasks are long-running, parallelizable, or need mid-flight steering.

<Warning>
<Note>
:::python
Async subagents are a preview feature targeted for `deepagents` 0.5.0. You can try them now by installing a prerelease version. Preview features are under active development and are not recommended for production use.

For Python, install the `0.5.0a1` prerelease with `--pre` or `--allow-prereleases`.
Async subagents are a preview feature available in `deepagents` 0.5.0. Preview features are under active development and APIs may change.
:::

:::js
Async subagents are a preview feature targeted for `deepagents` 1.9.0. You can try them now by installing a prerelease version. Preview features are under active development and are not recommended for production use.

For JavaScript, install the prerelease version explicitly, for example `deepagents@1.9.0-alpha.0`.
Async subagents are a preview feature available in `deepagents` 1.9.0. Preview features are under active development and APIs may change.
:::
</Warning>
</Note>

```mermaid
graph TB
Expand Down
40 changes: 25 additions & 15 deletions src/oss/deepagents/backends.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -220,62 +220,72 @@ NamespaceFactory = Callable[[BackendContext], tuple[str, ...]]

The `BackendContext` provides:
- `ctx.runtime.context` — User-supplied context passed via LangGraph's [context schema](https://langchain-ai.github.io/langgraph/concepts/runtime/) (for example, `user_id`)
:::python
- `ctx.runtime.server_info` — Server-specific metadata when running on LangGraph Server (assistant ID, graph ID, authenticated user)
Comment thread
hntrl marked this conversation as resolved.
- `ctx.runtime.execution_info` — Execution identity information (thread ID, run ID, checkpoint ID)
:::
:::js
- `ctx.runtime.serverInfo` — Server-specific metadata when running on LangGraph Server (assistant ID, graph ID, authenticated user)
- `ctx.runtime.executionInfo` — Execution identity information (thread ID, run ID, checkpoint ID)
:::
- `ctx.state` — Current agent state

For `assistant_id` and `thread_id`, use `langgraph.config.get_config()` inside the factory — these are available in LangGraph config metadata but not on the context schema.
:::python
<Note>
`ctx.runtime.server_info` and `ctx.runtime.execution_info` require `deepagents>=0.5.0`.
</Note>
:::

:::js
<Note>
`ctx.runtime.serverInfo` and `ctx.runtime.executionInfo` require `deepagents>=1.9.0`.
</Note>
:::

**Common namespace patterns:**

:::python
```python
from langgraph.config import get_config
from deepagents.backends import StoreBackend

# Per-user: each user gets their own isolated storage
backend = StoreBackend(
namespace=lambda ctx: (ctx.runtime.context.user_id,),
namespace=lambda ctx: (ctx.runtime.server_info.user.identity,), # [!code highlight]
)

# Per-assistant: all users of the same assistant share storage
backend = StoreBackend(
namespace=lambda ctx: (
get_config()["metadata"]["assistant_id"],
ctx.runtime.server_info.assistant_id, # [!code highlight]
),
)

# Per-thread: storage scoped to a single conversation
backend = StoreBackend(
namespace=lambda ctx: (
get_config()["configurable"]["thread_id"],
ctx.runtime.execution_info.thread_id, # [!code highlight]
),
)
```
:::

:::js
```typescript
import { getConfig } from "@langchain/langgraph";
import { StoreBackend } from "deepagents";

// Per-user: each user gets their own isolated storage
const backend = new StoreBackend({
namespace: (ctx) => [ctx.runtime.context.userId],
namespace: (ctx) => [ctx.runtime.serverInfo.user.identity], // [!code highlight]
});

// Per-assistant: all users of the same assistant share storage
const backend = new StoreBackend({
namespace: (ctx) => {
const config = getConfig();
return [config.metadata.assistantId];
},
namespace: (ctx) => [ctx.runtime.serverInfo.assistantId], // [!code highlight]
});

// Per-thread: storage scoped to a single conversation
const backend = new StoreBackend({
namespace: (ctx) => {
const config = getConfig();
return [config.configurable.threadId];
},
namespace: (ctx) => [ctx.runtime.executionInfo.threadId], // [!code highlight]
});
```
:::
Expand Down
Loading
Loading