MotirBuilding in public
MOTIR · moooon
onMotir
You’re viewing a public project. Anyone can view it — no account needed. Sign in to submit, upvote, or comment on requests.View-only — you can’t edit work items
MOTIR-2111

(motir-ai) The re-plan handler must READ `context.generateExplanations` and pass it to `runGenerationPass` — the consumer half

Done
Description

Repo: motir-ai. One PR. The CONSUMER half of the contract whose producer half is the motir-core card this is blocked_by — that card puts generateExplanations on the re-plan job envelope; this one makes the handler act on it.

The defect

src/jobs/handlers/replan.ts never mentions generateExplanations (verified on origin/main, 2026-08-04 — searched with python, since grep finds nothing in these long-line files). It calls runGenerationPass({ grounding, plan, situationPrompt: REPLAN_SITUATION_PROMPT }, sink) with no explanation option, so:

  • EXPLANATION_INSTRUCTION is never appended to the composed system prompt, and
  • buildGenerationTools never adds the explanationMd property to propose_node (it is added, and made REQUIRED, only when the flag is set),

meaning every node a re-plan proposes lands with no explanation, whatever the project's setting says. generateTree.ts is the working reference: it reads req?.context?.generateExplanations === true off the job envelope and spreads ...(generateExplanations ? { generateExplanations: true } : {}) into every runGenerationPass call.

Acceptance criteria

  • replan.ts reads the flag off the job envelope exactly as generateTree.ts does (same defensive read of requestJson.context, same strict === true) and passes it to runGenerationPass.
  • With the flag ON, a re-plan's propose_node proposals carry explanationMd and explanationSource: 'ai_draft' (the AI_DRAFT_EXPLANATION_SOURCE constant) through to addProposals — asserted by a test, not by inspection.
  • With the flag OFF or absent, the composed prompt and tool surface are byte-identical to today's — the same no-drift discipline generate_tree keeps.
  • The proposals materialize into work items whose explanation is recorded as AI-drafted (the explanationSource lockstep with motir-core's enum).
  • Do NOT read motir-core config directly — the flag rides the envelope; that boundary is the reason the producer card exists.
  • PR title carries MOTIR-<id>.

Context refs

  • src/jobs/handlers/replan.ts — the handler edited; its single runGenerationPass call site.
  • src/jobs/handlers/generateTree.ts — the working reference for both the envelope read and the option spread.
  • src/llm/treeGeneration.tsbuildGenerationSystemPrompt / EXPLANATION_INSTRUCTION / buildGenerationTools / AI_DRAFT_EXPLANATION_SOURCE (why the flag changes both prompt and tool surface).