Package org.mockserver.llm.analysis
Class LlmOptimisationReportService
java.lang.Object
org.mockserver.llm.analysis.LlmOptimisationReportService
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOptional filters; null/blank means "no filter".static final classThe built report plus the markdown brief, so callers render once. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(List<LogEventRequestAndResponse> pairs, LlmOptimisationReportService.Filter filter) Build a report from the given recorded pairs and filter.The configured redacted-body-field list, exposed for tests/callers.The redacted-header list reported in the bundle, exposed for tests/callers.redactor()The redactor used for the brief appendix, dataset exports and the agent-run diff — default sensitive headers/query params plus any configuredmockserver.fixtureBodyRedactFields.Render the brief for a previously built result, redacting the appendix.Render the CSV export (per-call rows + totals/verdict summary) for a previously built result.Render the captured session as an eval / fine-tune / promptfoo dataset for a previously built result.
-
Constructor Details
-
LlmOptimisationReportService
public LlmOptimisationReportService()
-
-
Method Details
-
build
public LlmOptimisationReportService.Result build(List<LogEventRequestAndResponse> pairs, LlmOptimisationReportService.Filter filter) Build a report from the given recorded pairs and filter. -
renderBrief
Render the brief for a previously built result, redacting the appendix. -
renderCsv
Render the CSV export (per-call rows + totals/verdict summary) for a previously built result. -
renderDataset
public String renderDataset(LlmOptimisationReportService.Result result, LlmDatasetExporter.DatasetFormat format) Render the captured session as an eval / fine-tune / promptfoo dataset for a previously built result. The exporter always redacts request and response content viaFixtureRedactor(default sensitive headers/query params plus any configuredmockserver.fixtureBodyRedactFields) before emission, so secrets and configured PII never reach the dataset. -
redactor
The redactor used for the brief appendix, dataset exports and the agent-run diff — default sensitive headers/query params plus any configuredmockserver.fixtureBodyRedactFields. Public so the diff callers (RESTPUT /llm/diffRuns, MCPdiff_agent_runs) redact each request the SAME way the export path does before surfacing decoded prompts. -
redactedHeaderNames
The redacted-header list reported in the bundle, exposed for tests/callers. -
redactedBodyFieldNames
The configured redacted-body-field list, exposed for tests/callers.
-