# execute_task_textual

> **Function** in `deepagents_cli`

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

Execute a task with output directed to Textual UI.

This is the Textual-compatible version of execute_task() that uses
the TextualUIAdapter for all UI operations.

## Signature

```python
execute_task_textual(
    user_input: str,
    agent: Any,
    assistant_id: str | None,
    session_state: Any,
    adapter: TextualUIAdapter,
    backend: Any = None,
    image_tracker: MediaTracker | None = None,
    context: CLIContext | None = None,
    *,
    sandbox_type: str | None = None,
    message_kwargs: dict[str, Any] | None = None,
    turn_stats: SessionStats | None = None,
) -> SessionStats
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `user_input` | `str` | Yes | The user's input message |
| `agent` | `Any` | Yes | The LangGraph agent to execute |
| `assistant_id` | `str \| None` | Yes | The agent identifier |
| `session_state` | `Any` | Yes | Session state with auto_approve flag |
| `adapter` | `TextualUIAdapter` | Yes | The TextualUIAdapter for UI operations |
| `backend` | `Any` | No | Optional backend for file operations (default: `None`) |
| `image_tracker` | `MediaTracker \| None` | No | Optional tracker for images (default: `None`) |
| `context` | `CLIContext \| None` | No | Optional `CLIContext` with model override and params, passed to the graph via `context=`. (default: `None`) |
| `sandbox_type` | `str \| None` | No | Sandbox provider name for trace metadata, or `None` if no sandbox is active. (default: `None`) |
| `message_kwargs` | `dict[str, Any] \| None` | No | Extra fields merged into the stream input message dict (e.g., `additional_kwargs` for persisting skill metadata in the checkpoint). (default: `None`) |
| `turn_stats` | `SessionStats \| None` | No | Pre-created `SessionStats` to accumulate into.  When the caller holds a reference to the same object, stats are available even if this coroutine is cancelled before it can return.  If `None`, a new instance is created internally. (default: `None`) |

## Returns

`SessionStats`

Stats accumulated over this turn (request count, token counts,
wall-clock time).

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/1ae053f347679e58562d2b81eb6d6e6e9bbf0b07/libs/cli/deepagents_cli/textual_adapter.py#L364)