# format_ask_user_transcript

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_ask_user_types/format_ask_user_transcript)

Render questions and answers as the `Q:`/`A:` transcript.

This is the text the `ask_user` tool returns to the model and persists in the
thread. The TUI renders that authoritative text literally, except for the
display-only re-render in `render_ask_user_transcript_for_display`, which
anchors on the known question text and gives up rather than guess.

Answers of every type are interpolated unescaped, so the encoding is not
unambiguously decodable: an answer containing a blank line followed by a
literal `Q: <text>\nA:` header is indistinguishable from a real block
boundary. Only the model reads it that way today. Any future decoder must
anchor on the known question text rather than on a generic `Q: ` pattern,
or a crafted answer can fabricate an extra question/answer pair.

For an answer `encode_multi_select_answer` produced, the JSON encoding does
close the hazard above: no encoded value can carry a raw line feed, so it
cannot fabricate a block boundary. This function cannot *rely* on that,
because it does not validate answers and not every answer is encoded — the
cancel and error paths in `_parse_answers` substitute `(cancelled)` and
`(error: ...)` placeholders for every question whatever its type, and a
non-TUI client resuming the interrupt can put arbitrary text in a
`multi_select` slot.

## Signature

```python
format_ask_user_transcript(
    questions: list[Question],
    answers: list[str],
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `questions` | `list[Question]` | Yes | Questions that were asked. Callers must pass questions whose `question` text is a non-empty string; `_validate_question_text`, attached to `Question.question`, enforces that before interrupting. The empty default below only keeps a caller that skips validation from raising `KeyError`. |
| `answers` | `list[str]` | Yes | Answers, positionally matched to `questions`. A missing entry falls back to `ASK_USER_NO_ANSWER`; extra entries are dropped. |

## Returns

`str`

Blank-line separated `Q: ...\nA: ...` blocks, one per question.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/_ask_user_types.py#L568)