# run_textual_app

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/app/run_textual_app)

Run the Textual application.

When `server_kwargs` is provided (and `agent` is `None`), the app starts
immediately with a "Connecting..." banner and launches the server in the
background.  Server cleanup is handled automatically after the app exits.

## Signature

```python
run_textual_app(
    *,
    agent: Any = None,
    assistant_id: str | None = None,
    backend: CompositeBackend | None = None,
    auto_approve: bool = False,
    cwd: str | Path | None = None,
    thread_id: str | None = None,
    resume_thread: str | None = None,
    initial_prompt: str | None = None,
    initial_skill: str | None = None,
    mcp_server_info: list[MCPServerInfo] | None = None,
    profile_override: dict[str, Any] | None = None,
    server_proc: ServerProcess | None = None,
    server_kwargs: dict[str, Any] | None = None,
    mcp_preload_kwargs: dict[str, Any] | None = None,
    model_kwargs: dict[str, Any] | None = None,
) -> AppResult
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent` | `Any` | No | Pre-configured LangGraph agent (optional). (default: `None`) |
| `assistant_id` | `str \| None` | No | Agent identifier for memory storage. (default: `None`) |
| `backend` | `CompositeBackend \| None` | No | Backend for file operations. (default: `None`) |
| `auto_approve` | `bool` | No | Whether to start with auto-approve enabled. (default: `False`) |
| `cwd` | `str \| Path \| None` | No | Current working directory to display. (default: `None`) |
| `thread_id` | `str \| None` | No | Thread ID for the session.  `None` when `resume_thread` is provided (the TUI resolves the final ID asynchronously). (default: `None`) |
| `resume_thread` | `str \| None` | No | Raw resume intent from `-r` flag. `'__MOST_RECENT__'` for bare `-r`, a thread ID string for `-r <id>`, or `None` for new sessions.  Resolved asynchronously during TUI startup. (default: `None`) |
| `initial_prompt` | `str \| None` | No | Optional prompt to auto-submit when session starts. (default: `None`) |
| `initial_skill` | `str \| None` | No | Optional skill name to invoke when session starts. (default: `None`) |
| `mcp_server_info` | `list[MCPServerInfo] \| None` | No | MCP server metadata for the `/mcp` viewer. (default: `None`) |
| `profile_override` | `dict[str, Any] \| None` | No | Extra profile fields from `--profile-override`, retained so later profile-aware behavior stays consistent with the CLI override, including model selection details, offload budget display, and on-demand `create_model()` calls such as `/offload`. (default: `None`) |
| `server_proc` | `ServerProcess \| None` | No | LangGraph server process for the interactive session. (default: `None`) |
| `server_kwargs` | `dict[str, Any] \| None` | No | Kwargs for deferred `start_server_and_get_agent` call. (default: `None`) |
| `mcp_preload_kwargs` | `dict[str, Any] \| None` | No | Kwargs for concurrent MCP metadata preload. (default: `None`) |
| `model_kwargs` | `dict[str, Any] \| None` | No | Kwargs for deferred `create_model()` call.  When provided, model creation runs in a background worker after first paint so the splash screen appears immediately. (default: `None`) |

## Returns

`AppResult`

An `AppResult` with the return code and final thread ID.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/bb27e62ebe44dd6e8104a504b1718ce87acc7ffa/libs/cli/deepagents_cli/app.py#L5028)