Skip to content

Ask cloud models for a list in one {"items": [...]} tool call; add scripts/compare_extraction.py - #67

Merged
strickvl merged 4 commits into
mainfrom
claude/project-thread-vp62j1
Nov 3, 2026
Merged

strickvl merged 4 commits into
mainfrom
claude/project-thread-vp62j1

Conversation

@strickvl

@strickvl strickvl commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Requested by Alex · project thread

The bug

Cloud list requests (all four extraction calls) went out in Instructor's parallel-tools mode: the model gets a Person tool and has to call it once per person, all in one reply. Nothing makes it call 12 times instead of once, and GPT-6 Luna often stopped early.

On 20 Guantánamo articles, run twice:

  • Events: exactly 1 event per article in all 40 calls, although the prompt asks for "ALL significant events".
  • People: on "How Congress helped thwart Obama's plan to close Guantánamo", only George W. Bush (both runs). The article also quotes Buck McKeon, John Brennan, Ali Abdullah Saleh, Thomas Hammarberg and others.
  • Same input, different answer: one article gave 10 people in run 1 and 1 person in run 2.

Asking for the list as one {"items": [...]} object, the way local calls already do, gave 2 to 14 events per article and the missing people. The experiment called cloud_generation() with that wrapper model, which is the same request this PR now makes. Wall-clock time for 20 articles went from 34 s to about 90 s, because Luna now writes the full lists.

Changes

  • src/utils/llm.py: any List[Model] request is wrapped as {"items": [...]} and unwrapped (_unwrap_list()). Cloud calls use TOOLS / ANTHROPIC_TOOLS with parallel_tool_calls=False. The parallel-tools modes and their fallback branch are gone. Multi-tool-call recovery now also accepts a list split across several {"items": [...]} calls.
  • src/utils/extraction_cache.py: the cache key now includes LIST_REQUEST_FORMAT. Extractions cached under the old format were the under-extracted ones, so they miss and get redone instead of being reused.
  • Tests: the parallel-tools tests are replaced with tests for the one-call request (OpenAI-style and Anthropic), split-list recovery, a strategy-1 retry that unwraps the list, and a test that the cache key changes with the list format.
  • scripts/compare_extraction.py: runs the pipeline's extraction step (no merging) per model on the same articles, then diffs the names (run / compare). It refuses to reuse an output folder whose article sample differs. This is the script behind the numbers above. Its outputs contain article-derived text, so keep them off GitHub.
  • CLAUDE.md: documents both.

Full write-up: https://claude.ai/artifact/XVuWG6tLT3jvBRdNtA6BUi

Checks

The local equivalents of just ci pass: ruff check, ruff format check and the file-length check. 570 tests passed (-m "not asyncio").

🤖 Generated with Claude Code

https://claude.ai/code/session_01FomNXd75yhujHo6xyWtGGp

…dels on the same articles and diff them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FomNXd75yhujHo6xyWtGGp
…s return the list in one tool call

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FomNXd75yhujHo6xyWtGGp
…one parallel call per item

GPT-6 Luna in parallel-tools mode returned 1 event per article on 20 of 20
articles (both runs) and sometimes a single person. The one-object request
returned 2-14 events and the missing people.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FomNXd75yhujHo6xyWtGGp
@strickvl strickvl self-assigned this Nov 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T10:48:38.913129Z 2cc45a8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0926308405

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/llm.py Resolved
Comment thread scripts/compare_extraction.py Resolved
…nged article sample in `compare_extraction`

Cached extractions from the one-call-per-item format were missing items, so
they must not be reused after the switch to one `{"items": [...]}` call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FomNXd75yhujHo6xyWtGGp
@strickvl
strickvl merged commit e8b4590 into main Nov 3, 2026
2 checks passed
@strickvl
strickvl deleted the claude/project-thread-vp62j1 branch November 3, 2026 10:48
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.

2 participants