Skip to content

Support configurable output language for LLM analyzer findings (e.g. via env var) #345

Description

@geosmart

Summary

LLMAnalyzerBase and its subclasses (semantic_security_discovery.py,semantic_quality_policy.py, semantic_developer_intent.py) hardcode ANALYZER_PROMPT as module-level Python string constants, and BASE_ANALYSIS_PROMPT in llm_analyzer_base.py has no language directive.

There's currently no way to make the free-text finding fields (message, explanation, remediation) come back in a language other than English without forking the package and editing prompt strings directly.

For non-English-speaking teams reviewing scan output (e.g. in CI comments,SARIF annotations shown to reviewers), this is a real friction point —every finding has to be manually translated or read through an LLM before it's usable internally.

Proposed change

Add a SKILLSPECTOR_OUTPUT_LANGUAGE (name open to bikeshedding) environment variable, following the same pattern as the existing
SKILLSPECTOR_MAX_LLM_CONCURRENCY:

def resolve_output_language() -> str | None:
    """Resolve the desired output language from SKILLSPECTOR_OUTPUT_LANGUAGE.

    Defaults to None (model's natural choice, currently English). When set,
    an instruction is appended to BASE_ANALYSIS_PROMPT telling the model to
    write message/explanation/remediation fields in the given language,
    while keeping rule_id values (e.g. SSD-1, SQP-3) untranslated.
    """
    return os.environ.get("SKILLSPECTOR_OUTPUT_LANGUAGE", "").strip() or None

And in BASE_ANALYSIS_PROMPT / LLMAnalyzerBase.build_prompt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions