Class LlmOptimisationReportService

java.lang.Object
org.mockserver.llm.analysis.LlmOptimisationReportService

public class LlmOptimisationReportService extends Object
Application service that turns captured REQUEST_RESPONSES log entries into an LlmOptimisationReport (JSON bundle) or a rendered Markdown brief, applying the optional session/host/provider filters, redaction, and the mockserver.llmOptimisationMaxCalls bound.

Lives in mockserver-core so both the control-plane REST endpoint and the export_optimisation_report MCP tool (mockserver-netty) share one implementation. Pure of transport: callers pass already-retrieved request/response pairs.

  • Constructor Details

    • LlmOptimisationReportService

      public LlmOptimisationReportService()
  • Method Details

    • build

      Build a report from the given recorded pairs and filter.
    • renderBrief

      public String renderBrief(LlmOptimisationReportService.Result result)
      Render the brief for a previously built result, redacting the appendix.
    • renderCsv

      public String renderCsv(LlmOptimisationReportService.Result result)
      Render the CSV export (per-call rows + totals/verdict summary) for a previously built result.
    • renderDataset

      Render the captured session as an eval / fine-tune / promptfoo dataset for a previously built result. The exporter always redacts request and response content via FixtureRedactor (default sensitive headers/query params plus any configured mockserver.fixtureBodyRedactFields) before emission, so secrets and configured PII never reach the dataset.
    • redactor

      public FixtureRedactor redactor()
      The redactor used for the brief appendix, dataset exports and the agent-run diff — default sensitive headers/query params plus any configured mockserver.fixtureBodyRedactFields. Public so the diff callers (REST PUT /llm/diffRuns, MCP diff_agent_runs) redact each request the SAME way the export path does before surfacing decoded prompts.
    • redactedHeaderNames

      public List<String> redactedHeaderNames()
      The redacted-header list reported in the bundle, exposed for tests/callers.
    • redactedBodyFieldNames

      public List<String> redactedBodyFieldNames()
      The configured redacted-body-field list, exposed for tests/callers.