fix: never disguise intake model failures as answers

#7
by thangvip - opened
src/compliment_forest/orchestrator.py CHANGED
@@ -12,7 +12,6 @@ from pydantic import ValidationError
12
  from .backends.image import ImageBackend, resolve_style
13
  from .backends.music import MusicBackend, build_music_prompt
14
  from .backends.text import TextBackend
15
- from .prompts import RECOVERY_INTAKE_QUESTIONS
16
  from .quality import (
17
  content_quality_issues,
18
  distinct_indices,
@@ -430,38 +429,18 @@ class ForestOrchestrator:
430
  ):
431
  rejected_questions.append(candidate_question)
432
 
433
- recovery = self._recovery_intake_question(history)
434
  self._trace(
435
  "intake_turn_failed",
436
  turn_index=len(history),
437
  history=history_payload,
438
  attempts=attempts,
439
  error=str(last_error) if last_error else "",
440
- recovered=True,
441
  model=self._text_model_name(),
442
  )
443
- self._trace(
444
- "intake_turn",
445
- turn_index=len(history),
446
- history=history_payload,
447
- output=recovery.model_dump(),
448
- attempts=attempts,
449
- fallback=True,
450
- error=str(last_error) if last_error else "",
451
- model=self._text_model_name(),
452
- )
453
- return recovery
454
-
455
- @staticmethod
456
- def _recovery_intake_question(history: list[IntakeTurn]) -> IntakeQuestion:
457
- previous_questions = [turn.question for turn in history]
458
- start = min(len(history), len(RECOVERY_INTAKE_QUESTIONS) - 1)
459
- for offset in range(len(RECOVERY_INTAKE_QUESTIONS)):
460
- index = (start + offset) % len(RECOVERY_INTAKE_QUESTIONS)
461
- question = IntakeQuestion.model_validate(RECOVERY_INTAKE_QUESTIONS[index])
462
- if not _question_repeats(question.question, previous_questions):
463
- return question
464
- raise ValueError("no distinct recovery intake question is available")
465
 
466
  def _plan(
467
  self,
 
12
  from .backends.image import ImageBackend, resolve_style
13
  from .backends.music import MusicBackend, build_music_prompt
14
  from .backends.text import TextBackend
 
15
  from .quality import (
16
  content_quality_issues,
17
  distinct_indices,
 
429
  ):
430
  rejected_questions.append(candidate_question)
431
 
 
432
  self._trace(
433
  "intake_turn_failed",
434
  turn_index=len(history),
435
  history=history_payload,
436
  attempts=attempts,
437
  error=str(last_error) if last_error else "",
 
438
  model=self._text_model_name(),
439
  )
440
+ raise ValueError(
441
+ f"intake question could not be generated after {attempts} attempts: "
442
+ f"{last_error}"
443
+ ) from last_error
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
 
445
  def _plan(
446
  self,
src/compliment_forest/prompts.py CHANGED
@@ -138,54 +138,6 @@ INTAKE_FOCUS_DIMENSIONS = (
138
  "what better or a small win would look like",
139
  )
140
 
141
- RECOVERY_INTAKE_QUESTIONS: tuple[dict[str, object], ...] = (
142
- {
143
- "question": "Which part of this feels loudest right now?",
144
- "options": [
145
- "What might go wrong",
146
- "What other people will think",
147
- "The unknown right after this",
148
- ],
149
- "rationale": "",
150
- },
151
- {
152
- "question": "What feels most at stake for you here?",
153
- "options": [
154
- "How I see myself",
155
- "How other people see me",
156
- "A chance I do not want to lose",
157
- ],
158
- "rationale": "",
159
- },
160
- {
161
- "question": "When does this feel hardest?",
162
- "options": [
163
- "When I have time alone with it",
164
- "When I am around the people involved",
165
- "Right before I have to act",
166
- ],
167
- "rationale": "",
168
- },
169
- {
170
- "question": "What kind of support would help most right now?",
171
- "options": [
172
- "Someone listening without fixing it",
173
- "A clearer next step",
174
- "More time and room to think",
175
- ],
176
- "rationale": "",
177
- },
178
- {
179
- "question": "What would a small win here look like?",
180
- "options": [
181
- "Just getting through it",
182
- "Doing one part well",
183
- "Feeling more honest about what I need",
184
- ],
185
- "rationale": "",
186
- },
187
- )
188
-
189
 
190
  def intake_messages(
191
  name: str,
 
138
  "what better or a small win would look like",
139
  )
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  def intake_messages(
143
  name: str,