Skip to content

fix: make the llm:choose prompt describe the enum schema it is sent with - #77

Merged
JNK234 merged 1 commit into
mainfrom
fix/choose-enum-prompt
Sep 8, 2026
Merged

fix: make the llm:choose prompt describe the enum schema it is sent with#77
JNK234 merged 1 commit into
mainfrom
fix/choose-enum-prompt

Conversation

@JNK234

@JNK234 JNK234 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

llm:choose failed on every call against Groq with HTTP 400 json_validate_failed. Found by the new T7 live test in #75.

The system prompt told the model to reply with only the bare option text ("no quotes, no punctuation"), while the request carried an EnumFormat schema requiring {"choice": "..."}. Groq validates the reply against the schema after generation rather than constraining decoding, so a model that followed the prompt produced south, and Groq rejected the response.

Fix

The prompt now asks for the same {"choice": "<option>"} object the schema enforces. Providers that ignore the constraint still work through the existing bare-text fallback in extractEnumChoice.

Tests

  • LLMChoosePromptMatchesEnumSchema (tests.txt) pins the prompt's final instruction to the schema shape via a new __TEST_ECHO_PROMPT_TAIL marker in DeterministicTestProvider.
  • Existing degradation tests unchanged and passing. 183/183 deterministic.
  • Live: e2e harness against Groq openai/gpt-oss-20b, 25/25 pass (was 24/25 before this fix).

The choose prompt told the model to reply with only the bare option text
while the request carried an EnumFormat schema requiring {"choice": ...}.
Providers that validate the reply against the schema after generation
(Groq) rejected the whole response with HTTP 400 json_validate_failed, so
llm:choose failed on every call there.

The prompt now asks for the same {"choice": "<option>"} object the schema
enforces. Providers that ignore the constraint still work through the
existing bare-text fallback.

Adds a deterministic test pinning the prompt's final instruction to the
schema shape, and a __TEST_ECHO_PROMPT_TAIL marker in the test provider.
Verified live against Groq gpt-oss-20b: 25/25 e2e assertions pass.
@JNK234
JNK234 merged commit 22fcbc5 into main Sep 8, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant