From 87332e50a1a99122c92c3f9c8153c5f8d7b4fa74 Mon Sep 17 00:00:00 2001 From: sfw Date: Fri, 20 Mar 2026 16:10:45 -0600 Subject: [PATCH] Fix follow-up generation always requesting practice content The backend's _generation_request_payload() set requested_content_type in the continue action payload but never set intent. The frontend fell back to its hardcoded default of intent='practice', so every follow-up request asked for practice problems regardless of what the backend planned (explanations, worked examples, etc.). Add intent to the payload derived from content_type, and change the frontend default from practice to explanation so the backend decides. Co-Authored-By: Claude Opus 4.6 --- frontend/src/app/workspace.ts | 4 ++-- src/dibble/services/content_workflow.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/workspace.ts b/frontend/src/app/workspace.ts index 67d7a7a..5b6ba58 100644 --- a/frontend/src/app/workspace.ts +++ b/frontend/src/app/workspace.ts @@ -71,8 +71,8 @@ export const initialGenerationForm: GenerationFormState = { learning_session_id: 'session-fractions-bridge', target_kc_ids: 'KC-1', target_lo_ids: 'LO-1', - intent: 'practice', - requested_content_type: 'practice_problem', + intent: 'explanation', + requested_content_type: '', learner_prompt: 'Use a supportive tone and name the transfer move explicitly.', curriculum_context: 'Equivalent fractions', } diff --git a/src/dibble/services/content_workflow.py b/src/dibble/services/content_workflow.py index b8513aa..4e51f6f 100644 --- a/src/dibble/services/content_workflow.py +++ b/src/dibble/services/content_workflow.py @@ -66,6 +66,19 @@ logger = logging.getLogger(__name__) +_CONTENT_TYPE_TO_INTENT: dict[str | None, str] = { + RequestedContentType.micro_explanation.value: "explanation", + RequestedContentType.worked_example.value: "explanation", + RequestedContentType.practice_problem.value: "practice", + RequestedContentType.remedial_micro_module.value: "remediation", + RequestedContentType.assessment_probe.value: "assessment", +} + + +def _intent_for_content_type(content_type: str | None) -> str: + """Map a content type string to the matching ``ContentIntent`` value.""" + return _CONTENT_TYPE_TO_INTENT.get(content_type, "explanation") + class LearnerProfileNotFoundError(LookupError): def __init__(self, student_id: UUID) -> None: @@ -1036,6 +1049,7 @@ def _generation_request_payload( ), "target_kc_ids": list(next_step.target_kc_ids), "target_lo_ids": self._string_list(request_context.get("target_lo_ids")), + "intent": _intent_for_content_type(next_step.content_type), "requested_content_type": next_step.content_type, "curriculum_context": list(generated_content.response.curriculum_context), "source_generation_id": generated_content.generation_id,