Skip to content

feat: deep research module + tool-result loop & citation parser fixes#89

Open
nyddle wants to merge 3 commits intomainfrom
deepresearch
Open

feat: deep research module + tool-result loop & citation parser fixes#89
nyddle wants to merge 3 commits intomainfrom
deepresearch

Conversation

@nyddle
Copy link
Copy Markdown
Contributor

@nyddle nyddle commented Apr 24, 2026

Summary

  • Новый модуль deep_research (backend/giga_agent/modules/deep_research/): planner → search → read → reflect → compose → critique; forced-mode UI, отчёт с нумерованными цитатами [N].
  • Fix: бесконечный цикл python/shell в middlewares/tool_result.py. Раньше большой stdout сохранялся в sandbox-файл и LLM получал «читай через python», что порождало новый stdout → новый файл → снова prompt. Теперь для python/shell результат не сохраняется; output режется до GIGA_AGENT_TOOL_MAX_SIZE с подсказкой переписать код (срезы/агрегация).
  • Fix: парсер источников в front/src/components/deep_research/citations.tsx распознавал только строгий шаблон ## Источники + [N] Title: URL — иначе цитаты оставались сырыми [1][2]. Теперь поддерживаются Источники/Sources/References/Литература/Библиография, падежи, **bold**-заголовки, markdown-ссылки [Title](URL), разделители | : — –, URL в <…>, и fallback на хвостовой блок без заголовка.

Test plan

  • В /deep_research прогнать длинный запрос, убедиться, что цитаты в отчёте рендерятся как favicon-чипы, не как [1][2].
  • Запустить python-tool с большим выводом (>25KB), убедиться, что агент не крутится в цикле «читай файл по пути» и получает обрезанный output с подсказкой.
  • Регрессия: мелкие python-результаты (<25KB) проходят без изменений; остальные tool'ы по-прежнему сохраняются в result_path.
  • Frontend: ToolMessage.tsx для run_deep_research (план подсвечивается), TextMarkdown.tsx (иконки в тексте + drawer).

🤖 Generated with Claude Code

nyddle and others added 3 commits April 24, 2026 12:19
Adds a plan→search→read→reflect→compose research pipeline that reads
full pages via Jina Reader and composes a cited markdown report.

Backend:
- modules/deep_research: StateGraph with planner, search, read, reflect,
  compose, critique, finalize nodes; registered in GigaAgent and in
  langgraph.json as a subgraph.
- graph_factory: reads config.configurable.deep_research_forced and
  pins tool_choice="run_deep_research" + injects a <forced_mode> prompt
  hint so the search tool is actually invoked.
- vectorstores/qdrant: skip close() on local SQLite-backed QdrantClient
  during shutdown (SQLite raised ProgrammingError from worker thread).

Frontend:
- InputArea: lupa toggle that forces deep research for the next send,
  wires configurable and requests Notification permission on first use.
- ToolMessage / Message / config: progress labels, per-tool rendering
  for run_deep_research, DeepResearchPlan card with live subquestion
  status, browser notification when DR tool completes while tab is
  hidden.
- attachments/TextMarkdown + components/deep_research/citations: parse
  the "## Источники" section, replace inline [N] / [N, M] citations
  with stacked-favicon chips, open a right-side sources drawer on click
  (Perplexity-style).
- lib/notifications: permission + hidden-tab notification helper.
- attachments/HtmlSandbox: sandboxed iframe renderer for generated HTML.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… limit

Middleware used to persist every oversized tool result to sandbox and return
"read it via python" — but python/shell themselves pipe that read back through
the same middleware, endlessly creating new result_path files. Inline python
and shell outputs instead and truncate them to GIGA_AGENT_TOOL_MAX_SIZE with a
hint to reshape the code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The parser only matched "## Источники|Sources" plus "[N] Title: URL" with a
strict separator, so common variants (Список/Использованные/References,
markdown-linked titles, pipe/parenthesised URLs, bare URLs) silently fell back
to plain [N] digits in the report. Accept more heading variants, four line
formats, and fall back to the trailing citation block when no heading is
recognised.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant