Skip to content

fix(metadata): give gpt-5-mini reasoning headroom for tagging/validation succeed#250

Merged
houtanb merged 1 commit into
forecastingresearch:mainfrom
drozado:fix/metadata-reasoning-token-budget
Jul 8, 2026
Merged

fix(metadata): give gpt-5-mini reasoning headroom for tagging/validation succeed#250
houtanb merged 1 commit into
forecastingresearch:mainfrom
drozado:fix/metadata-reasoning-token-budget

Conversation

@drozado

@drozado drozado commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #249

gpt-5-mini is a reasoning model. Calling it with max_output_tokens=50 (tag) / 500
(validate) and default (medium) reasoning makes it exhaust the budget on reasoning tokens and
return status=incomplete (max_output_tokens) every time, so metadata silently fell back to
category="Other" / valid_question=True.

Changes

  • helpers/metadata_llm.py: pass reasoning={"effort": "minimal"} (covers tag + validate).
  • tag_questions/main.py: max_output_tokens 50 → 512.
  • validate_questions/main.py: max_output_tokens 500 → 1024.
  • test_model_request_params.py: assert a reasoning policy is present rather than pinning the
    exact effort value, so future model/reasoning/budget changes don't break the test.

Summary by CodeRabbit

  • New Features

    • Improved metadata responses with lighter reasoning guidance for faster, more efficient results.
    • Increased response limits for question tagging and validation to reduce the likelihood of truncated outputs.
  • Bug Fixes

    • More reliable question categorization and validation when generating longer model responses.
  • Tests

    • Updated automated checks to reflect the new model response settings.

Copilot AI review requested due to automatic review settings July 2, 2026 06:27
@drozado drozado requested a review from houtanb July 2, 2026 06:28

Copilot AI 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.

Pull request overview

This PR fixes metadata tagging/validation failures caused by gpt-5-mini exhausting its token budget on reasoning, which led to systematic fallbacks (category="Other" / valid_question=True) and silent mislabeling in the metadata pipeline under src/metadata/.

Changes:

  • Configure metadata LLM calls to use reasoning={"effort": "minimal"} to prevent reasoning-token starvation.
  • Increase max_output_tokens for tagging (50 → 512) and validation (500 → 1024) to give responses enough output budget.
  • Relax the request-parameter unit test to assert that a reasoning policy is present without pinning an exact effort value.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/helpers/metadata_llm.py Adds a minimal reasoning policy to metadata model requests to avoid incomplete responses.
src/metadata/tag_questions/main.py Increases tagging output budget to reduce incomplete/empty outputs and fallback categorization.
src/metadata/validate_questions/main.py Increases validation output budget to reduce incomplete outputs and fallback validity labeling.
src/tests/test_model_request_params.py Updates test expectations to require a reasoning policy while avoiding brittle effort-value assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@drozado drozado force-pushed the fix/metadata-reasoning-token-budget branch from bf530c7 to 6351a60 Compare July 2, 2026 06:58
Comment thread src/tests/test_model_request_params.py Outdated
@nikbpetrov

Copy link
Copy Markdown
Collaborator

@houtanb This is a good catch for a bug and raises the possibility that not all LLM args/setup is being forwarded/works exactly as expected. Perhaps a smoke test-like cli can run a few more reqests and check outputs for systematic problems/refusals. But that's separate.

LGTM

@drozado drozado force-pushed the fix/metadata-reasoning-token-budget branch from 6351a60 to 6d01eea Compare July 8, 2026 08:16
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 50524307-5ac0-423e-8944-77636d198780

📥 Commits

Reviewing files that changed from the base of the PR and between 6d01eea and 067519a.

📒 Files selected for processing (4)
  • src/helpers/metadata_llm.py
  • src/metadata/tag_questions/main.py
  • src/metadata/validate_questions/main.py
  • src/tests/test_model_request_params.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/helpers/metadata_llm.py
  • src/metadata/tag_questions/main.py
  • src/metadata/validate_questions/main.py
  • src/tests/test_model_request_params.py

📝 Walkthrough

Walkthrough

This change adds reasoning={"effort": "minimal"} to the shared metadata model call and raises max_output_tokens in tag_questions and validate_questions, with a matching test update.

Changes

Metadata LLM budget and reasoning fix

Layer / File(s) Summary
Shared metadata LLM reasoning effort
src/helpers/metadata_llm.py, src/tests/test_model_request_params.py
get_metadata_model_response() now passes reasoning={"effort": "minimal"} to get_response(), and the test asserts this kwarg is included in the call.
Caller token budget increases
src/metadata/tag_questions/main.py, src/metadata/validate_questions/main.py
max_output_tokens is raised from 50 to 512 in tag_questions and from 500 to 1024 in validate_questions for their respective LLM calls.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main fix: increasing reasoning headroom for metadata tagging and validation.
Linked Issues check ✅ Passed The changes match the issue fix by setting minimal reasoning and raising output token limits for tagging and validation.
Out of Scope Changes check ✅ Passed All code changes stay within the requested metadata tagging/validation fix and test update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

…idation

`gpt-5-mini` is a reasoning model, so a 50-token cap with default (medium)
reasoning returns `status=incomplete (max_output_tokens)` and every question
silently fell back to `category="Other"` / `valid_question=True`. Set
reasoning effort to `minimal` and raise the output budgets so tagging and
validation complete.
@houtanb houtanb force-pushed the fix/metadata-reasoning-token-budget branch from 6d01eea to 067519a Compare July 8, 2026 19:33
@houtanb houtanb merged commit c0d475e into forecastingresearch:main Jul 8, 2026
2 checks 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.

Metadata tagging & validation silently mislabel all newly-processed questions (gpt-5-mini reasoning starves the token budget)

4 participants