read_until_prompt
Read serial output until a device prompt appears, capturing full multi-page responses for interactive CLI sessions. Avoids truncation by continuously buffering until timeout.
Instructions
Read accumulated output until a prompt appears, or until timeout.
This is the right tool for interactive CLI sessions (routers, switches, shells).
It reads from the background buffer until prompt is seen, then returns
everything up to and including it, leaving anything after the prompt in the
buffer for the next read. Because the reader runs continuously, large multi-page
outputs are captured in full rather than being cut off by a fixed delay.
Typical flow: send_text("show version", line_ending="LF", clear_buffer_first=True) read_until_prompt(prompt="# ")
Args:
prompt: The text that marks the end of output. Literal by default, e.g.
"# ", "> ", "login: ", "$ ", "Password:". Common device prompts end in
"# " (enable) or "> " (user). Note the match is searched in everything
received, including the echo of your own command, so prefer a prompt
with its trailing space over a bare "#" or ">" when the command text
itself could contain that character.
timeout: Max seconds to wait for the prompt to appear.
regex: Treat prompt as a Python regular expression instead of literal
text (e.g. r"[\w.-]+[#>] ?$" to match a hostname-style prompt).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regex | No | ||
| prompt | No | # | |
| timeout | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |