Adolanium
7caee2898b
perf(agent): stop rebuilding the streamed reply text on every delta
...
`_record_streamed_assistant_text` grew the turn's visible text with `+=`
on an attribute. Python only grows a string in place when the target is a
local variable, so this copied the whole text on every delta.
The loop runs once per streamed token, so a reply of length N costs about
N squared in copying. A 200 KB answer arriving in 4-character deltas
moves several billion characters and burns seconds of CPU in the loop the
file itself calls the hottest one in the agent.
The text is now kept as a list of pieces and joined when read. Reading
happens at turn end and on interrupt, not per delta, so the whole turn is
linear in the length of the reply. `_fire_stream_delta` used to join on
every token just to ask if the text was empty. That check now looks at
the parts list.
`_current_streamed_assistant_text` becomes a property over that list, so
the seven readers and the call sites that clear it between turns keep
working unchanged. Reading does not collapse the pieces, because a delta
landing between the join and the write back would be lost.
Measured with 8-character deltas: adding 20k deltas to an already long
text took 3.1 times as long as the first 20k before, and 0.9 times after.
2026-09-03 04:46:41 +05:30
..
2026-06-19 11:37:51 -07:00
2026-09-01 21:36:09 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 15:24:14 -07:00
2026-07-29 13:10:23 -07:00
2026-08-03 22:54:54 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-06-28 00:57:42 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-28 03:46:24 -07:00
2026-07-29 13:10:23 -07:00
2026-08-10 09:38:28 +05:30
2026-08-24 04:47:07 +05:30
2026-08-16 10:51:11 -07:00
2026-08-07 18:07:19 +05:30
2026-08-24 14:58:42 +05:30
2026-07-27 11:53:48 -04:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 15:37:24 -07:00
2026-08-14 21:41:26 -07:00
2026-07-29 13:10:23 -07:00
2026-08-06 17:03:10 +05:30
2026-08-02 23:48:42 +05:30
2026-08-16 10:27:52 -07:00
2026-08-23 18:25:19 -07:00
2026-07-29 13:10:23 -07:00
2026-08-29 19:10:06 -07:00
2026-09-02 13:28:41 +05:30
2026-08-19 19:42:07 -07:00
2026-08-29 22:29:28 +05:30
2026-08-02 21:17:49 +05:30
2026-08-04 11:25:18 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-24 15:30:30 +05:30
2026-07-29 13:10:23 -07:00
2026-08-04 23:33:39 +05:30
2026-07-29 13:10:23 -07:00
2026-08-28 02:47:34 +05:30
2026-07-29 13:10:23 -07:00
2026-08-15 10:22:47 +05:30
2026-07-29 13:10:23 -07:00
2026-08-28 07:51:31 -07:00
2026-08-20 00:16:22 -07:00
2026-08-14 21:39:44 -07:00
2026-07-29 15:37:24 -07:00
2026-07-29 13:10:23 -07:00
2026-08-26 07:16:04 -07:00
2026-09-01 03:48:40 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-08 14:56:38 +05:30
2026-08-16 01:55:51 -07:00
2026-08-04 11:26:15 +05:30
2026-07-29 13:10:23 -07:00
2026-08-17 13:19:58 +05:30
2026-06-27 19:23:15 -07:00
2026-07-29 13:10:23 -07:00
2026-08-14 21:19:55 -07:00
2026-07-02 04:51:56 +05:30
2026-07-29 13:10:23 -07:00
2026-08-04 17:53:17 +00:00
2026-07-29 13:10:23 -07:00
2026-08-15 13:36:25 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-09-01 21:42:19 -07:00
2026-07-29 13:10:23 -07:00
2026-08-03 20:43:38 +05:30
2026-07-26 20:59:21 -07:00
2026-08-08 19:17:02 -07:00
2026-09-01 20:55:35 +05:30
2026-08-13 12:31:02 -07:00
2026-06-27 04:39:26 -07:00
2026-08-30 05:16:10 -07:00
2026-08-15 00:36:03 -07:00
2026-07-29 13:10:23 -07:00
2026-09-01 08:30:45 -07:00
2026-09-02 16:57:21 +05:30
2026-08-31 12:22:55 -07:00
2026-08-13 21:38:30 +02:00
2026-08-03 22:53:32 +05:30
2026-08-28 05:17:26 -07:00
2026-08-28 04:58:06 -07:00
2026-09-01 09:28:31 -07:00
2026-08-20 11:36:54 +05:30
2026-08-30 19:46:11 -07:00
2026-09-03 03:09:06 +05:30
2026-09-01 02:00:05 -07:00
2026-07-05 13:42:46 -07:00
2026-08-23 16:04:41 -07:00
2026-08-23 18:25:19 -07:00
2026-07-29 15:37:24 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-09-02 00:55:42 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 15:21:26 -07:00
2026-07-29 13:10:23 -07:00
2026-08-14 21:41:26 -07:00
2026-07-29 13:10:23 -07:00
2026-09-01 14:56:30 +05:30
2026-07-29 13:10:23 -07:00
2026-08-21 15:02:29 -07:00
2026-07-29 13:10:23 -07:00
2026-07-31 21:52:36 -07:00
2026-09-01 22:14:06 -07:00
2026-07-29 13:10:23 -07:00
2026-08-30 05:15:54 -07:00
2026-08-21 17:24:22 +05:30
2026-08-30 05:16:10 -07:00
2026-08-30 05:16:10 -07:00
2026-07-29 15:21:26 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-01 05:06:00 -07:00
2026-07-28 19:06:59 +05:30
2026-08-21 00:24:32 -07:00
2026-08-03 10:01:45 +05:30
2026-09-01 10:27:06 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 15:37:24 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 15:37:24 -07:00
2026-08-12 19:15:02 -07:00
2026-07-29 13:10:23 -07:00
2026-08-25 03:55:55 -07:00
2026-07-29 15:37:24 -07:00
2026-09-01 03:48:40 +05:30
2026-09-01 22:42:27 +05:30
2026-08-06 02:22:08 +05:30
2026-08-13 02:03:40 -07:00
2026-08-29 19:13:12 -07:00
2026-07-29 19:48:37 -07:00
2026-08-20 00:03:50 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-03 19:32:50 +05:30
2026-08-25 12:12:08 +05:30
2026-08-25 00:18:35 -07:00
2026-09-01 22:14:06 -07:00
2026-07-29 13:10:23 -07:00
2026-09-02 00:55:42 -07:00
2026-08-31 13:11:41 -07:00
2026-08-23 18:25:19 -07:00
2026-08-02 16:16:36 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-06 03:53:38 +05:30
2026-08-29 06:37:06 -07:00
2026-07-29 13:10:23 -07:00
2026-08-14 22:11:30 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-16 01:55:00 -07:00
2026-09-03 04:46:41 +05:30
2026-07-29 13:10:23 -07:00
2026-08-29 12:45:43 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-08 14:08:44 -07:00
2026-08-30 05:16:10 -07:00
2026-08-25 12:12:08 +05:30
2026-07-11 03:44:02 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-08-30 05:16:10 -07:00
2026-07-29 13:10:23 -07:00
2026-08-13 21:38:30 +02:00
2026-08-10 10:01:44 +05:30
2026-06-10 12:39:44 -07:00
2026-07-29 13:10:23 -07:00
2026-09-01 20:55:35 +05:30
2026-08-14 21:20:03 -07:00
2026-08-29 18:23:07 -07:00
2026-08-18 02:12:13 -07:00
2026-07-29 13:10:23 -07:00
2026-09-02 00:26:57 -07:00
2026-08-29 11:33:05 +05:30
2026-07-29 13:10:23 -07:00
2026-08-03 20:43:38 +05:30
2026-09-02 16:57:21 +05:30
2026-09-01 03:19:59 +05:30
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00
2026-07-29 13:10:23 -07:00