Skip to content

fix: guard against None structured output in MakeAssumptionsTask and DistillAssumptionsTask#180

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

fix: guard against None structured output in MakeAssumptionsTask and DistillAssumptionsTask#180
neoneye merged 1 commit intoPlanExeOrg:mainfrom
VoynichLabs:fix/structured-output-null-guard

Conversation

@82deutschmark
Copy link
Copy Markdown
Collaborator

After PR #168 replaced json.loads() with chat_response.raw (Pydantic model), there is no guard for the case where chat_response.raw is None. When a local/small model fails structured output validation (e.g. GLM 4.7 Flash schema echo), chat_response.raw is None, causing AttributeError on .question_assumption_list with no logged error — silent exit-0 instead of a clear failure.

Fix: add explicit None check on chat_response.raw in both make_assumptions.py and distill_assumptions.py, raising a descriptive ValueError so the pipeline logs the failure properly and retry logic can handle it.

Fixes MakeAssumptionsTask silent failure observed in GLM 4.7 Flash runs. Related to commit f766959.

…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.
@neoneye neoneye merged commit 70918f9 into PlanExeOrg:main Mar 7, 2026
3 checks passed
@neoneye neoneye deleted the fix/structured-output-null-guard branch March 7, 2026 20:44
HejEgonBot pushed a commit to VoynichLabs/PlanExe2026 that referenced this pull request Mar 7, 2026
…ibility

DeduplicationAnalysis schema (List[LeverDecision] with lever_id, classification,
justification) causes schema echo in GLM 4.7 Flash and Qwen 3.5-35B. The model
returns the schema description object instead of values.

Fix: add LeverClassificationDecision (2 fields: classification enum + justification
string). Call as_structured_llm(LeverClassificationDecision) once per lever.
Code provides lever_id from context and assembles DeduplicationAnalysis in-memory.
Failed levers default to keep to avoid data loss.

Backward-compatible: save_raw(), save_clean(), to_dict() unchanged.
Adds None-guard on chat_response.raw per PR PlanExeOrg#180 pattern.
HejEgonBot pushed a commit to VoynichLabs/PlanExe2026 that referenced this pull request Mar 8, 2026
chat_response.message.content can be None when OpenAILike returns an
empty structured response. Add None guard consistent with PR PlanExeOrg#180 pattern.
Also guard chat_response.raw to raise a clear error instead of
AttributeError downstream.
82deutschmark pushed a commit to VoynichLabs/PlanExe2026 that referenced this pull request Mar 8, 2026
chat_response.message.content can be None when OpenAILike returns an
empty structured response. Add None guard consistent with PR PlanExeOrg#180 pattern.
Also guard chat_response.raw to raise a clear error instead of
AttributeError downstream.
82deutschmark pushed a commit to VoynichLabs/PlanExe2026 that referenced this pull request Mar 8, 2026
chat_response.message.content can be None when OpenAILike returns an
empty structured response. Add None guard consistent with PR PlanExeOrg#180 pattern.
Also guard chat_response.raw to raise a clear error instead of
AttributeError downstream.
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