fix: surface child research errors in supervisor_tools (#283)#286
Open
pii (rohan4naik) wants to merge 1 commit into
Open
fix: surface child research errors in supervisor_tools (#283)#286pii (rohan4naik) wants to merge 1 commit into
pii (rohan4naik) wants to merge 1 commit into
Conversation
supervisor_tools guarded its ConductResearch exception handler with `if is_token_limit_exceeded(...) or True:`. The `or True` made the branch fire for every exception, so any child researcher failure was silently treated as a normal end of the research phase. The graph then continued to final_report_generation and could produce a final report from failed/incomplete research. Remove the `or True`: token-limit errors still end the phase gracefully with the notes gathered so far, but any other exception is now re-raised and surfaced instead of being swallowed. This mirrors the error handling in final_report_generation, which also distinguishes token-limit errors from genuine failures. Add regression tests covering both paths. Fixes langchain-ai#283
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Deep Research agent’s supervisor_tools where all child ConductResearch exceptions were incorrectly treated as a graceful end-of-research due to an unconditional or True, allowing the outer graph to proceed to final_report_generation after partial research failure.
Changes:
- Remove the unconditional exception-swallowing logic so only token-limit errors end the research phase gracefully; other errors are re-raised.
- Add regression tests to ensure non-token child failures propagate and token-limit failures still return
goto=END.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/open_deep_research/deep_researcher.py |
Fixes supervisor_tools exception handling to surface non-token child research errors. |
tests/test_supervisor_tools.py |
Adds regression tests covering error propagation vs token-limit graceful termination. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
329
to
331
| if raw_notes_concat: | ||
| update_payload["raw_notes"] = [raw_notes_concat] | ||
|
|
Comment on lines
+55
to
+64
| def test_token_limit_ends_research_phase_gracefully(): | ||
| """A token-limit error should end the research phase with gathered notes.""" | ||
| with ( | ||
| patch.object(researcher_subgraph, "ainvoke", side_effect=_boom), | ||
| patch.object(deep_researcher, "is_token_limit_exceeded", return_value=True), | ||
| ): | ||
| command = asyncio.run(supervisor_tools(_supervisor_state(), _CONFIG)) | ||
|
|
||
| assert command.goto == END | ||
| assert "research_brief" in command.update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
supervisor_toolsguarded itsConductResearchexception handler with:The trailing
or Truemade the branch fire for every exception, so any child researcher failure was silently treated as a normal end of the research phase. The top-level graph then continued fromresearch_supervisortofinal_report_generation, meaning a run could still produce a final report after part of the research fan-out had failed.Fix
Remove the
or True:This mirrors the error handling already used in
final_report_generation, which distinguishes token-limit errors from genuine failures rather than treating all errors the same.Testing
Added
tests/test_supervisor_tools.pywith two regression tests:test_child_research_error_is_surfaced— a non-token-limit child failure now propagates instead of returninggoto=END.test_token_limit_ends_research_phase_gracefully— a token-limit error still ends the phase with the gathered notes.ruff checkclean on changed files.Fixes #283