> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain (deepagents)

> Back deepagents and other LangGraph-style agents with a Mirage workspace via LangchainWorkspace.

[deepagents](https://github.com/langchain-ai/deepagents) is LangChain's framework for long-horizon coding agents. It accepts a pluggable `backend` for filesystem and shell operations, Mirage ships one.

<Note>
  Node only. The Mirage adapter is runtime-agnostic, but `deepagents` and the LangChain runtime depend on Node APIs.
</Note>

## Install

```bash theme={null}
pnpm add @struktoai/mirage-agents @struktoai/mirage-node deepagents @langchain/anthropic
```

## Usage

```ts theme={null}
import { MountMode, OpsRegistry, RAMResource, Workspace } from '@struktoai/mirage-node'
import { ChatAnthropic } from '@langchain/anthropic'
import { createDeepAgent } from 'deepagents'
import {
  LangchainWorkspace,
  buildSystemPrompt,
  extractText,
} from '@struktoai/mirage-agents/langchain'

const ram = new RAMResource()
const ops = new OpsRegistry()
for (const op of ram.ops()) ops.register(op)
const ws = new Workspace({ '/': ram }, { mode: MountMode.WRITE, ops })

const agent = createDeepAgent({
  model: new ChatAnthropic({ model: 'claude-sonnet-4-6' }),
  systemPrompt: buildSystemPrompt({
    mountInfo: { '/': 'In-memory filesystem (read/write)' },
  }),
  backend: new LangchainWorkspace(ws),
})

const result = await agent.invoke({
  messages: [{ role: 'user', content: 'Create /report.md and summarize.' }],
})
for (const text of extractText(result.messages)) {
  console.log(text)
}
```

## Exports

| Symbol               | Purpose                                                                         |
| -------------------- | ------------------------------------------------------------------------------- |
| `LangchainWorkspace` | `Backend` implementation for deepagents, wires reads, writes, edits, and shell. |
| `extractText`        | Returns `string[]` of text blocks from an array of LangChain messages.          |
| `buildSystemPrompt`  | Generates a system prompt that describes mounted paths to the model.            |

## Examples

* [`examples/typescript/agents/langchain/ram_deepagent.ts`](https://github.com/strukto-ai/mirage/blob/main/examples/typescript/agents/langchain/ram_deepagent.ts), RAM-only sandbox.
* [`examples/typescript/agents/langchain/s3_deepagent.ts`](https://github.com/strukto-ai/mirage/blob/main/examples/typescript/agents/langchain/s3_deepagent.ts), read-only S3 exploration.
