Skip to content

fix(deep-research): keep oversized context from collapsing to empty#1802

Open
XiaojuCH wants to merge 1 commit into
assafelovic:mainfrom
XiaojuCH:fix-deep-research-empty-context
Open

fix(deep-research): keep oversized context from collapsing to empty#1802
XiaojuCH wants to merge 1 commit into
assafelovic:mainfrom
XiaojuCH:fix-deep-research-empty-context

Conversation

@XiaojuCH

@XiaojuCH XiaojuCH commented Jun 9, 2026

Copy link
Copy Markdown

Fixes #1770.

This PR prevents deep-research context trimming from collapsing to an empty string when the first retained context item alone exceeds MAX_CONTEXT_WORDS.

What changed:

  • update trim_context_to_word_limit() in gpt_researcher/skills/deep_research.py
  • when the first candidate item already exceeds the cap and nothing has been retained yet, keep a truncated version of that item instead of returning an empty context
  • add focused regression tests in tests/test_deep_research_parsing.py

Why:

Validation:

  • .\.venv\Scripts\python.exe -m pytest tests/test_deep_research_parsing.py -q
  • 25 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deep mode: writer receives empty {context} placeholder; report rejection across all params (post-PR-#1637, current master)

1 participant