# AssistantMessage

> **Class** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage)

Widget displaying an assistant message with markdown support.

Uses MarkdownStream for smoother streaming instead of re-rendering
the full content on each update. Once a stream finishes, the message
is re-rendered from the complete source via `Markdown.update()` to
work around Textualize/textual#6518: `MarkdownFence._update_from_block`
refreshes the visible `Label` but leaves `_highlighted_code` pinned to
the first chunk, so any later recompose (click, focus change, theme
update) re-yields the stale value and wrapped fenced-code bodies vanish.
A full re-parse rebuilds every fence with correct internal state.

Streamed tokens are coalesced in `_pending_append` and flushed to the
`MarkdownStream` on a throttled timer (`_STREAM_FLUSH_INTERVAL`). Writing
every token immediately forced a markdown re-parse per chunk on the UI
event loop, which starved keyboard input while the model streamed.
Batching the writes keeps the event loop free so typing stays responsive.

## Signature

```python
AssistantMessage(
    self,
    content: str = '',
    **kwargs: Any = {},
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content` | `str` | No | Initial markdown content (default: `''`) |
| `**kwargs` | `Any` | No | Additional arguments passed to parent (default: `{}`) |

## Extends

- `Vertical`

## Constructors

```python
__init__(
    self,
    content: str = '',
    **kwargs: Any = {},
) -> None
```

| Name | Type |
|------|------|
| `content` | `str` |


## Properties

- `DEFAULT_CSS`

## Methods

- [`compose()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/compose)
- [`on_mount()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/on_mount)
- [`append_content()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/append_content)
- [`write_initial_content()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/write_initial_content)
- [`stop_stream()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/stop_stream)
- [`set_content()`](https://reference.langchain.com/python/deepagents-code/widgets/messages/AssistantMessage/set_content)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/0412009c5441bef8d75a427e1da8909e33ab5b56/libs/code/deepagents_code/widgets/messages.py#L628)