Skip to content

Two bugs when using Anthropic provider: company_name prepended to filename + temperature error on Sonnet 5 #19

Description

@volkov596

Bug 1: company_name is prepended to filename before the date

When using the Anthropic provider, the extracted company_name field is prepended to the filename before the date, producing output like:

Melchers 2024_Melchers_Corrosion-Steel_Paper.pdf
Department of Transport 2015_TMR_Crevice-Corrosion_Guide.pdf

This is a problem for users renaming engineering or academic documents where the counterparty concept does not apply. The company_name field is always extracted and inserted even when the prompt_extension explicitly instructs the model not to include names before the year.

The company_name field in DocumentMetadata and the corresponding extraction logic in build_system_prompt appear to be hardcoded for invoice workflows with no way to suppress them via config.

Suggested fix: Add a config option such as extract_company: false under the pdf: section that sets company_name to empty string and skips the company extraction prompt entirely.


Bug 2: temperature parameter causes 400 error on claude-sonnet-5

Setting temperature: 0.0 in config (or leaving it at the default) causes a 400 error when using claude-sonnet-5:

Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 
'message': '`temperature` is deprecated for this model.'}}

Anthropic deprecated the temperature parameter for Claude Sonnet 5. The parameter is currently passed unconditionally in extract_metadata_from_text, extract_metadata_from_images, and extract_metadata_from_text_and_images.

Suggested fix: Conditionally exclude temperature from kwargs when the model is claude-sonnet-5, for example:

if not (provider == "anthropic" and "sonnet-5" in config["ai"].get("model", "")):
    kwargs["temperature"] = config["ai"].get("temperature", 0.0)

Environment:

  • Provider: Anthropic
  • Models tested: claude-sonnet-4-6, claude-sonnet-5
  • OS: Windows 11
  • Use case: Engineering document library (research papers, standards, guides, manuals)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions