Skip to content

fix(api): cost estimate uses active extraction config (closes #406)#407

Merged
aaronsb merged 1 commit into
mainfrom
fix/issue-406-extraction-model-label
May 24, 2026
Merged

fix(api): cost estimate uses active extraction config (closes #406)#407
aaronsb merged 1 commit into
mainfrom
fix/issue-406-extraction-model-label

Conversation

@aaronsb
Copy link
Copy Markdown
Owner

@aaronsb aaronsb commented May 24, 2026

Closes #406.

Summary

api/app/services/job_analysis.py hardcoded "gpt-4o" as the final fallback for the cost-estimate model label. When neither job_data.extraction_model nor the OPENAI_EXTRACTION_MODEL env var was set, the estimate panel rendered "Extraction (gpt-4o)" regardless of the actually configured provider — even though the same panel's Total row used the configured provider's pricing (Anthropic Sonnet etc.). Misleading side-by-side discrepancy.

Fix: consult load_active_extraction_config() (the same DB-backed helper the real extraction code path uses) as the middle layer of the fallback chain. Env-var and hard-coded defaults remain as last-resort fallbacks.

Test plan

  • Live verification: submitted an ingest with --no-approve against a fresh dev env configured for Claude Sonnet. Cost estimate now shows Extraction (claude-sonnet-4-6) (was Extraction (gpt-4o) before the fix).
  • pytest tests/unit/ — 469 pass

Files

  • api/app/services/job_analysis.py — fallback chain now consults load_active_extraction_config()

…d-coded gpt-4o (#406)

The cost-estimate label on the ingest workspace showed "Extraction
(gpt-4o)" regardless of the actually configured extraction provider,
while the same panel's Total row correctly reflected the configured
model's pricing — a visible inconsistency that misled operators
investigating spend.

Root cause was the fallback chain in JobAnalysisService:

  extraction_model = job_data.get("extraction_model") \
      or os.getenv("OPENAI_EXTRACTION_MODEL", "gpt-4o")

When job_data lacked an override (normal for the estimate-before-
submit flow) and OPENAI_EXTRACTION_MODEL wasn't set, the label
defaulted to the hard-coded string. The actual extraction code path
loads the active config from kg_api.ai_extraction_config via
load_active_extraction_config(), which is the authoritative source.

Consult that same helper as the next layer in the fallback so the
estimate matches what extraction will actually charge for. The env-
var and hard-coded defaults remain as last-resort fallbacks for
environments without a populated extraction config.
@aaronsb aaronsb merged commit 6ad88fa into main May 24, 2026
3 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.

Cost estimate: extraction model label hard-coded to gpt-4o instead of active config

1 participant