Skip to content

fix: prevent Stage 4 literature search from silently falling back - #310

Open
pikaqiu2333 wants to merge 1 commit into
aiming-lab:mainfrom
pikaqiu2333:codex/fix-stage4-os-scope
Open

fix: prevent Stage 4 literature search from silently falling back#310
pikaqiu2333 wants to merge 1 commit into
aiming-lab:mainfrom
pikaqiu2333:codex/fix-stage4-os-scope

Conversation

@pikaqiu2333

@pikaqiu2333 pikaqiu2333 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove the function-local os import that broke environment-variable lookup in Stage 4.
  • Restore Semantic Scholar and OpenAlex API key resolution from configuration and environment variables.
  • Add regression coverage for key precedence, search configuration, Web Search augmentation, orchestrator execution, and fallback behavior.

Root Cause

A function-local import os caused Python to treat os as a local variable throughout _execute_literature_collect.

Stage 4 accessed os.environ before reaching that import, raising UnboundLocalError. The existing broad exception handler then caught the error and silently skipped the real literature APIs.

This regression was introduced by my changes in #299. I’m sorry I missed the interaction with the existing function-local import during testing. Thank you for reporting it in #309. This PR fixes the issue and adds orchestration-level regression coverage to prevent the same silent fallback from recurring.

Validation

  • Stage 4 regression tests: 8 passed
  • Configuration and literature tests: 78 passed
  • Executor tests: 207 passed
  • Full suite: 2869 passed, 57 skipped
  • Real literature retrieval:
    • 18 real candidates
    • 12 OpenAlex and 6 arXiv results
    • 0 placeholders
    • 18 BibTeX entries
    • Semantic Scholar rate limiting was handled without breaking the remaining providers

Two pre-existing Windows shell-related tests remain environment-specific and are unrelated to this change.

Fixes #309

@pikaqiu2333
pikaqiu2333 marked this pull request as ready for review July 23, 2026 07:34
@pikaqiu2333
pikaqiu2333 force-pushed the codex/fix-stage4-os-scope branch from 5e125c6 to 5a53c86 Compare July 23, 2026 07:44
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.

Stage 4 literature search silently falls back due to UnboundLocalError: os

1 participant