Commit d2d311e
authored
fix: race condition in new_task tool for native protocol (#9655)
The pendingNewTaskToolCallId was being set AFTER startSubtask() returned.
However, startSubtask() contains a 500ms delay during which the subtask
could complete. If the subtask completed during this window, completeSubtask()
would be called before pendingNewTaskToolCallId was set, causing it to
fall through to the XML protocol path and add a text message instead of
a proper tool_result block, breaking the API conversation structure.
This fix moves the pendingNewTaskToolCallId assignment to happen BEFORE
calling startSubtask(), ensuring the ID is set before the subtask starts.
If the subtask creation fails, the pending ID is cleared.1 parent 400d0cd commit d2d311e
1 file changed
+15
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
136 | | - | |
| 148 | + | |
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 152 | + | |
| 153 | + | |
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
| |||
0 commit comments