Skip to content

refactor: migrate make_assumptions and distill_assumptions to structured output#168

Merged
neoneye merged 1 commit intoPlanExeOrg:mainfrom
VoynichLabs:fix/structured-output-migration
Mar 7, 2026
Merged

refactor: migrate make_assumptions and distill_assumptions to structured output#168
neoneye merged 1 commit intoPlanExeOrg:mainfrom
VoynichLabs:fix/structured-output-migration

Conversation

@82deutschmark
Copy link
Copy Markdown
Collaborator

Summary

Migrates two task files from manual JSON parsing to structured output using the existing as_structured_llm + chat_response.raw pattern already used throughout the codebase (e.g. premise_attack.py, identify_potential_levers.py).

Changes

make_assumptions.py

  • Removes json.loads(chat_response.message.content) with try/except block
  • Uses chat_response.raw (typed as ExpertDetails) directly
  • Builds assumption_list from Pydantic model attributes instead of dict key access
  • Uses expert_details.model_dump() for json_response

distill_assumptions.py

  • Removes json.loads(chat_response.message.content) with try/except block
  • Uses chat_response.raw.model_dump() directly

Result

repair_json_util.py is now unreferenced by any task file. All assumption-related tasks now use the consistent structured output pattern.

…red output

Remove manual json.loads(chat_response.message.content) calls in favor of
using chat_response.raw (the Pydantic model returned by as_structured_llm).

- make_assumptions.py: use ExpertDetails from chat_response.raw directly
- distill_assumptions.py: use AssumptionDetails.model_dump() from chat_response.raw

repair_json_util.py is now unreferenced by any task file.
@neoneye
Copy link
Copy Markdown
Member

neoneye commented Mar 7, 2026

looks good

@neoneye neoneye merged commit f766959 into PlanExeOrg:main Mar 7, 2026
3 checks passed
@neoneye neoneye deleted the fix/structured-output-migration branch March 7, 2026 19:27
HejEgonBot pushed a commit to VoynichLabs/PlanExe2026 that referenced this pull request Mar 7, 2026
…tions

PR PlanExeOrg#168 migrated make_assumptions.py and distill_assumptions.py from
json.loads(chat_response.message.content) to chat_response.raw (Pydantic
model). However, when a local/small model echoes the schema instead of
producing valid JSON (the schema-echo failure mode seen with GLM 4.7
Flash and Qwen 3.5-35B), as_structured_llm may return None for .raw.

With the old code a clear ValueError('Invalid JSON response from LLM.')
was raised and logged. With the new code, None.question_assumption_list
raises AttributeError with no log entry, causing a silent exit-0 that
leaves no output files and no error in the pipeline log.

Fix: add an explicit None-guard immediately after reading chat_response.raw
in both files, raising ValueError with a descriptive message that names
the model compatibility issue. This restores the explicit failure signal
so operators can diagnose which model is incompatible rather than seeing
a silent stop.
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.

2 participants