Skip to content

Add opt-in compact prompts mode to reduce LLM token usage #456

Description

@leogasparini

LLM analyzer prompts carry redundant content that inflates token consumption without improving detection quality:

  • Line numbers are zero-padded (L001: instead of L1:), adding ~3 wasted characters per line across every file sent to the LLM.
  • The meta-analyzer embeds each finding's context snippet in the prompt alongside the full line-numbered file content, duplicating the same code.
  • The OverallAssessment field in MetaAnalyzerResult is generated by the LLM but never consumed downstream (the report node computes its own risk score).
  • Several analyzer prompts (SSD, SDI, SQP, meta-analyzer, TP4) contain repeated phrasing, verbose formatting (horizontal rules, per-section rule-ID reminders already present in the
    summary table), and filler sentences.

Proposal: Introduce a SKILLSPECTOR_COMPACT_PROMPTS=true environment variable that activates condensed prompt variants. Default behavior stays identical for backward compatibility.
When enabled:

  1. Line numbers drop zero-padding (L1: instead of L001:)
  2. Meta-analyzer omits redundant finding context from the prompt
  3. Meta-analyzer uses a slimmer structured output schema (no OverallAssessment)
  4. All five LLM analyzer prompts use condensed variants (same semantic content, less formatting overhead)
  5. BASE_ANALYSIS_PROMPT output guidelines shortened from 5 lines to 2

Estimated savings per scan: 400-800 input tokens from prompt condensation, ~375 input tokens per call from line numbering (on a 500-line file), 30-50 output tokens per meta-analyzer call from schema reduction, plus variable savings from context omission.

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