Commit 9dd7962
committed
fix(collectives): surface failed requests instead of passing them on
Three findings from the Copilot review on #159, all the same shape: a failed
request was treated as a successful one.
get_page_content only special-cased 404. Any other failure was handed back as
if the response body were the page's markdown - in practice a DAV error
document, which the agent would then summarize as page content. The 404
contract is unchanged and still comes first; every 4xx and 5xx now raises.
update_page_content discarded the PUT response entirely and always reported
success, so a refused write looked like a completed one to the agent and to
the user. The realistic case is the one the tool's own docstring warns about:
a page held open in the real-time editor is locked, the write comes back 423,
and the tool said it had gone through.
Both use response.raise_for_status(). The review suggested it verbatim for the
read; the write is the same problem and gets the same treatment. It is also
what nc_py_api's own check_error() uses internally. Its message carries status,
reason and URL, and graph.py's handle_tool_error hands repr() of the exception
back to the model, so the agent sees what failed rather than a bare status
code. 2xx multi-status responses do not raise.
is_available caught bare, which also swallows asyncio.CancelledError and turns
a cancellation during tool discovery into "Collectives unavailable" while
discovery carries on - freezing an incomplete tool list in the 60-second cache
around it. It now catches Exception, so cancellation propagates.
Signed-off-by: Pavlinchen <69079839+Pavlinchen@users.noreply.github.com>1 parent 2df6b3d commit 9dd7962
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| |||
281 | 283 | | |
282 | 284 | | |
283 | 285 | | |
284 | | - | |
| 286 | + | |
285 | 287 | | |
286 | 288 | | |
0 commit comments