Repository navigation
Commit b195cc5
committed
fix(cli): stream agent output as plain text instead of Rich markup
stream_process_output is the only reader of an agent's stdout pipe in
`agentex agents run`, and it printed every line with
console.print(f"[dim]{prefix}:[/dim] {decoded_line}"), so the agent's
own output was parsed as Rich markup:
- A line with an unmatched closing tag, such as "[INST] hi [/INST]" or
"loaded [/etc/hosts]", raised MarkupError. That reached the outer
handler and ended the loop, which is the freeze the function's
docstring warns about: nothing drains the pipe any more and the agent
blocks once it fills.
- Bracketed words were eaten as styles: "[info] starting" printed as
" starting", "deps: [pkg==1.0]" as "deps: ".
- Markup rendering of long lines is slow and blocks the event loop while
it runs: an 82,000-character line took 28.9 s here, which is also why
test_large_line_within_the_limit_is_streamed_in_full times out on
slower machines.
Print a Text with a dim prefix and the line as plain text instead. The
read loop, limits and error handling are unchanged.
Verified by driving stream_process_output with an in-memory reader: on
main the first markup-like line stops streaming and nothing after it is
printed; here every line prints verbatim and the 82,000-character line
prints in 0.01 s. Two new tests cover the reader surviving markup-like
output and printing it verbatim; tests/lib/cli/test_run_handlers_streaming.py
passes (7 tests, 1.5 s).1 parent 6d68f3a commit b195cc5
2 files changed
Lines changed: 68 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
294 | | - | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
| |||
61 | 78 | | |
62 | 79 | | |
63 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
64 | 101 | | |
65 | 102 | | |
66 | 103 | | |
| |||
98 | 135 | | |
99 | 136 | | |
100 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
101 | 167 | | |
102 | 168 | | |
103 | 169 | | |
| |||
0 commit comments