From 9ea6c3aaa5e4a5c05e8111249b7f7ac9c5723406 Mon Sep 17 00:00:00 2001 From: Marcus van Elst Date: Tue, 7 Apr 2026 00:09:25 +0200 Subject: [PATCH] =?UTF-8?q?M5=20AP-002=20JSON-Only-Erwartung=20in=20KI-Anf?= =?UTF-8?q?rage=20erg=C3=A4nzt=20und=20Tests=20gesch=C3=A4rft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AiRequestComposer.java | 82 +++++++++++++++---- .../service/AiRequestComposerTest.java | 66 +++++++++++++++ 2 files changed, 130 insertions(+), 18 deletions(-) diff --git a/pdf-umbenenner-application/src/main/java/de/gecheckt/pdf/umbenenner/application/service/AiRequestComposer.java b/pdf-umbenenner-application/src/main/java/de/gecheckt/pdf/umbenenner/application/service/AiRequestComposer.java index 0a2ce6c..edf11fa 100644 --- a/pdf-umbenenner-application/src/main/java/de/gecheckt/pdf/umbenenner/application/service/AiRequestComposer.java +++ b/pdf-umbenenner-application/src/main/java/de/gecheckt/pdf/umbenenner/application/service/AiRequestComposer.java @@ -15,16 +15,25 @@ import de.gecheckt.pdf.umbenenner.domain.model.PromptIdentifier; *
  • The loaded prompt content (from the external prompt file)
  • *
  • The stable prompt identifier (derived from the prompt source)
  • *
  • The extracted document text (already limited to max characters if needed)
  • + *
  • An explicit JSON-only response format specification
  • *
  • The exact character count that was sent (for traceability)
  • * *

    - * Order and structure: The composition follows a fixed, documented order - * to ensure that another implementation would not need to guess how the prompt and document - * are combined. The prompt is presented first, followed by the document text, with clear - * structural markers to distinguish between them. + * Composition order: The request follows a fixed, documented order: + *

      + *
    1. Prompt content (instruction)
    2. + *
    3. Prompt identifier marker
    4. + *
    5. Document text marker
    6. + *
    7. Document text content
    8. + *
    9. Response format expectation (JSON-only specification)
    10. + *
    *

    - * JSON-only response expectation: The request is constructed with the - * explicit expectation that the AI will respond with a JSON object containing: + * This fixed order ensures reproducibility and allows another implementation to + * understand the request structure without guessing. + *

    + * JSON-only response expectation: The actual composed request includes + * an explicit specification that the AI must respond with a JSON object containing + * exactly these fields: *