Commit d18c2e2
fix(deep_research): resolve DeepResearchAgent returning None
When DeepResearchTool's inner initiate_chat() calls terminate via tool
execution (confirm_summary, generate_subquestions, confirm_answer), the
default _last_msg_as_summary extracts content from the last
sender->recipient message, which is a tool_call with content=None.
This causes result.summary to return an empty string, making the
DeepResearchAgent return None to the user.
Add _extract_last_result_with_prefix() static method that walks
chat_result.chat_history in reverse to find the actual answer message
by its expected prefix, falling back to result.summary when no match
is found. Replace all 3 bare return result.summary calls with this
helper.
Includes 5 unit tests covering: prefix extraction, multiple matches,
fallback to summary, None content handling, and empty history.
Fixes #1770
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 78b245f commit d18c2e2
File tree
2 files changed
+87
-9
lines changed- autogen/tools/experimental/deep_research
- test/tools/experimental/deep_research
2 files changed
+87
-9
lines changedLines changed: 27 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| |||
132 | 148 | | |
133 | 149 | | |
134 | 150 | | |
135 | | - | |
136 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
137 | 155 | | |
138 | 156 | | |
139 | 157 | | |
| |||
142 | 160 | | |
143 | 161 | | |
144 | 162 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
| |||
154 | 172 | | |
155 | 173 | | |
156 | 174 | | |
157 | | - | |
| 175 | + | |
158 | 176 | | |
159 | 177 | | |
160 | 178 | | |
| |||
228 | 246 | | |
229 | 247 | | |
230 | 248 | | |
231 | | - | |
| 249 | + | |
232 | 250 | | |
233 | 251 | | |
234 | 252 | | |
| |||
326 | 344 | | |
327 | 345 | | |
328 | 346 | | |
329 | | - | |
| 347 | + | |
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
17 | 77 | | |
18 | 78 | | |
19 | 79 | | |
| |||
0 commit comments