Commit 90f1687
Add verbose timing telemetry and improvements to terminal commands performance (#257)
* Add verbose timing telemetry and fix 8s timeout bug in process tools
This commit adds comprehensive performance telemetry and fixes a critical bug
where interact_with_process waited 8+ seconds despite output arriving in 2-6ms.
Changes:
- Add TimingInfo and OutputEvent types to track performance metrics
- Add verbose_timing parameter to start_process, read_process_output, and interact_with_process
- Implement detailed timing collection including exit reasons and output event timelines
- Fix interact_with_process bug: removed broken duplicate stream listeners
- Optimize polling: reduced interval from 200ms to 50ms (4x faster response)
- Update tool documentation with performance debugging instructions
Performance improvement: REPL interactions now complete in 50-100ms instead of 8s timeout (160x faster).
Telemetry shows:
- Exit reason (early_exit_quick_pattern, early_exit_periodic_check, process_exit, timeout)
- Total duration and time to first output
- Complete timeline of output events with timestamps and sources
- Which detection mechanism triggered early exit
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix listener cleanup bug in read_process_output
Fixed critical bug where removeAllListeners('data') was removing
TerminalManager's persistent listeners, breaking all future calls.
Problem:
- read_process_output attached temporary listeners for immediate detection
- Used removeAllListeners('data') to clean up, which removed ALL listeners
- This broke TerminalManager's accumulator, causing future getNewOutput() to return empty
- Second call to read_process_output would always timeout
Solution:
- Store references to our specific detector functions
- Use .off('data', specificFunction) instead of .removeAllListeners('data')
- Only removes our temporary listeners, preserves TerminalManager's listeners
Testing:
- Added test-listener-bug.js that reproduces the issue
- Test verifies multiple sequential read_process_output calls work correctly
- All tests pass after fix
Credit: Fix suggested by code reviewer
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Strengthen test validation for listener cleanup bug
Improved test-listener-bug.js to validate output content, not just presence:
Changes:
- Added validation that output contains expected result "4" from "2 + 2"
- Added validation that output contains REPL prompt ">"
- More detailed success messages showing what was validated
- Better error messages if validation fails
This prevents false positives where the test could pass even if:
- Output is corrupt or incomplete
- REPL prompt detection stops working
- Listeners are partially broken
All validations pass, confirming:
✓ Output contains correct computation result
✓ REPL prompt is properly detected
✓ Multiple sequential calls work correctly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>1 parent babda00 commit 90f1687
File tree
6 files changed
+558
-115
lines changed- src
- tools
6 files changed
+558
-115
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
654 | | - | |
| 654 | + | |
655 | 655 | | |
656 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
657 | 665 | | |
658 | 666 | | |
659 | | - | |
| 667 | + | |
660 | 668 | | |
661 | 669 | | |
662 | 670 | | |
| |||
690 | 698 | | |
691 | 699 | | |
692 | 700 | | |
693 | | - | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
694 | 710 | | |
695 | 711 | | |
696 | 712 | | |
| |||
741 | 757 | | |
742 | 758 | | |
743 | 759 | | |
744 | | - | |
| 760 | + | |
| 761 | + | |
745 | 762 | | |
746 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
747 | 772 | | |
748 | 773 | | |
749 | | - | |
| 774 | + | |
750 | 775 | | |
751 | 776 | | |
752 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
104 | | - | |
| 111 | + | |
105 | 112 | | |
106 | 113 | | |
107 | | - | |
| 114 | + | |
108 | 115 | | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
112 | 135 | | |
113 | 136 | | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
117 | 145 | | |
118 | 146 | | |
119 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
120 | 159 | | |
121 | 160 | | |
122 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
123 | 168 | | |
124 | 169 | | |
125 | 170 | | |
| |||
130 | 175 | | |
131 | 176 | | |
132 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
133 | 183 | | |
134 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
135 | 196 | | |
136 | 197 | | |
137 | 198 | | |
| |||
140 | 201 | | |
141 | 202 | | |
142 | 203 | | |
| 204 | + | |
143 | 205 | | |
144 | 206 | | |
145 | 207 | | |
| |||
152 | 214 | | |
153 | 215 | | |
154 | 216 | | |
| 217 | + | |
155 | 218 | | |
156 | 219 | | |
157 | 220 | | |
| |||
169 | 232 | | |
170 | 233 | | |
171 | 234 | | |
172 | | - | |
| 235 | + | |
173 | 236 | | |
174 | 237 | | |
175 | 238 | | |
176 | 239 | | |
177 | 240 | | |
178 | | - | |
| 241 | + | |
179 | 242 | | |
180 | 243 | | |
| 244 | + | |
181 | 245 | | |
182 | 246 | | |
183 | 247 | | |
| |||
0 commit comments