You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance PDF reading capabilities and improve agent response handling
- Introduced a new `PdfReadRequest` model to facilitate explicit PDF read actions from the UI, ensuring structured input for PDF-related queries.
- Updated the agent's request handling to incorporate `pdf_read_request`, allowing for better management of user intent regarding PDF reading.
- Enhanced the `build_agent_request_turn_context` function to process PDF read requests, integrating them into the agent's decision-making process.
- Implemented fallback mechanisms for handling PDF read failures, improving user feedback and citation enrichment based on PDF read results.
- Updated various components to support the new PDF reading features, including state management and response generation, ensuring a cohesive user experience.
Copy file name to clipboardExpand all lines: docs/analysis/external-research-tools-implementation-review-2026-05-15.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -634,3 +634,15 @@ The architecture is in good shape. The next improvement should be either:
634
634
635
635
**Execution detail:** Phase 3 **closeout** (optional OpenAlex live smoke, diagnostics `status` decision) and Phase 4 **staged delivery** (PDF artifact pipeline → SSE → trust → Ask UI → live matrix) are spelled out in `docs/analysis/external-research-tools-workplan-2026-05-15.md` (Phase 3 **Remaining / Closeout**, Phase 4 Stages 1–8, PR slicing PR 4b–PR 9).
636
636
637
+
## Phase 4 honest closure (2026-05-15) — shipped in repo
638
+
639
+
-**Typed API:**`PdfReadRequest` + relaxed `question` when `pdf_read_request` is present; machine token `__sg_pdf_read_action__` replaces legacy `"[pdf-read-action]"` in the canonical path.
640
+
-**Orchestrator:**`pdf_read_orchestrator.execute_pdf_read` is the single fetch/parse/cache path for `read_external_pdf` and optional SSE prefetch (`pdf_read_validating` / `pdf_read_downloading` / `pdf_read_extracting`) before the LangGraph stream.
-**Policy:**`EXTERNAL_RESEARCH_WEB_TOOL_NAMES` vs `read_external_pdf`; explicit `pdf_read_request` bypasses web-research denylist for PDF only; `pdf_reading_mode=off` blocks agent PDF unless explicit request; LLM `allowed_domains` / `blocked_domains` on the tool are ignored (server policy).
643
+
-**Evidence:** PDF success uses `evidence_quality=variable`; failed `read_external_pdf` hydrates citations like `web_fetch` / `unpaywall` failures.
644
+
-**UI:** Native token + i18n user-turn label; pdf-only submit; product-step strings for PDF prefetch.
-**Acceptance:** httpx-mocked unit tests, manifest/registry sync tests, product_step mapping, documented per-tool denylist/toggle; optional live smoke when key/rate limits allow.
241
241
-**Raised:** 2026-05-15, **updated:** 2026-05-15 (OpenAlex search split out as delivered; backlog tracks Semantic Scholar only)
242
242
243
+
### [OPEN] Durable PDF read artifacts (cross-process)
244
+
-**Area:**`science_graphrag/agent/tools/external/pdf_read_*`, future `stores/` or Postgres
245
+
-**Issue:** Phase 4 ships in-process LRU+TTL cache and optional prefetch job bookkeeping only; workers lose cache on restart and there is no durable artifact row for audit/replay.
246
+
-**Proposal:** add persisted artifact metadata (url hash, sizes, status, excerpt pointer) keyed by `parent_turn_id` / workspace; optional object storage for raw bytes; align GC with operator TTL knobs.
247
+
-**Acceptance:** repeat read after cold start hits persisted excerpt or cleanly refetches; trace-review shows stable `artifact_id`; repository unit tests.
-**`progress_pct`**: `float | null` (0..1) — взвешенный прогресс по стадиям (running = 0.5 веса), чтобы UI рисовал общий бар без «рваных» процентов.
444
444
-**`stages[i].expected_duration_ms`**: `int | null` — средняя длительность стадии по последним успешным jobs (Postgres), подсказка для ETA на фронте.
445
+
446
+
## 7) Settings — LLM snapshot (Settings page)
447
+
448
+
Реализация: `GET/PATCH /v1/settings/llm`, `DELETE /v1/settings/llm/secret`, `DELETE /v1/settings/llm/vision-secret` в [`science_graphrag/api/settings.py`](../../science_graphrag/api/settings.py); снимок материализуется через [`science_graphrag/settings/snapshot_llm.py`](../../science_graphrag/settings/snapshot_llm.py) и [`science_graphrag/settings/llm_runtime.py`](../../science_graphrag/settings/llm_runtime.py).
449
+
450
+
**`GET /v1/settings`** — в `llm` помимо `status`, `effective`, `advanced_controls` ожидаются:
451
+
452
+
-**`tasks`**: нормализованные профили задач (`extraction`, `chat`, `vision`, `embeddings`) с полями модели и **masked** метаданными ключа (`source`, опционально `masked`).
453
+
-**`diagnostics`**: операторский блок (`operator_env_variables`, `notes`) — для раскрываемой секции «для операторов», не для основного UX.
454
+
455
+
**`PATCH /v1/settings/llm`** — тело включает обязательные поля провайдера (`base_url`, `model`, `temperature`, `timeout_seconds`) и опционально:
456
+
457
+
-**`chat_model`**, **`vl_model`**, **`vl_base_url`** — клиент может опускать поля, если persisted значение не меняется (рекомендуемый контракт для UI: не «материализовать» унаследованные из env дефолты в JSON при сохранении несвязанных полей).
458
+
-**`api_key`** — сохраняется в server secret store как основной OpenAI-compatible ключ.
459
+
-**`vision_api_key`** — отдельный UI-managed ключ для PDF/Vision; пустая строка может трактоваться как сброс override (см. обработку в API).
460
+
461
+
**`DELETE /v1/settings/llm/vision-secret`** — удаляет только vault-запись vision-ключа; основной `llm.api_key` и прочие поля не трогаются. После удаления effective vision снова наследует env/default по правилам resolver.
0 commit comments