zylon-ai/private-gpt · error · ValueError

No output object was generated

Error message

No output object was generated

What it means

Raised by SummarizeWorkflow.run_summary after the workflow finished: the caller passed output_cls (a Pydantic model for structured output) but the resulting SummarizeResultEvent.output_obj is None or falsy. The workflow step that should have populated output_obj (from a PydanticResponse) either never matched a PydanticResponse or the model returned an empty object. It is a post-execution integrity check, not an LLM transport error.

Source

Thrown at private_gpt/components/workflows/others/summary.py:127

        """Run the summarization workflow and return formatted content blocks."""
        handler: WorkflowHandler | None = None
        try:
            handler = self.run(
                start_event=SummarizeInputEvent(
                    model_id=model_id,
                    prompt=prompt,
                    instructions=instructions,
                    additional_instructions=additional_instructions,
                    output_cls=output_cls,
                    empty_response_fallback=empty_response_fallback,
                )
            )
            result: SummarizeResultEvent = await handler

            if output_cls:
                response = result.output_obj
                if not response:
                    raise ValueError("No output object was generated")
                if not isinstance(response, BaseModel):
                    raise TypeError(
                        f"Expected output object to be a BaseModel, got {type(response)}"
                    )
                return [TextBlock(text=response.model_dump_json())]
            else:
                summary = result.summary
                summary_text = summary if isinstance(summary, str) else None

                if not summary_text:
                    raise ValueError("No summary was generated")

                return [TextBlock(text=summary_text)]
        except asyncio.CancelledError as e:
            if handler:
                await handler.cancel_run()
            raise e

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Check what the workflow step returned: log the SummarizeResultEvent — if summary is set but output_obj is None, the query engine did not produce a PydanticResponse for your output_cls.
  2. Verify output_cls is a valid pydantic BaseModel and is passed through SummarizeInputEvent to the query engine's response_mode='structured'/'pydantic' configuration.
  3. If the LLM returned unparseable content, tighten the output_cls schema (simpler field types, defaults) or add prompt instructions demanding JSON matching the schema.
  4. If empty results are expected (e.g. empty corpus), supply empty_response_fallback and handle it before requesting structured output.

Example fix

// before
result_blocks = await workflow.run_summary(prompt=p, output_cls=MySummary)

// after
result: SummarizeResultEvent = await workflow.run(start_event=SummarizeInputEvent(..., output_cls=MySummary))
if output_cls and result.output_obj is None:
    # engine produced a plain summary, not structured output
    result_blocks = [TextBlock(text=result.summary or "")]
else:
    result_blocks = [TextBlock(text=result.output_obj.model_dump_json())]
Defensive patterns

Strategy: validation

Validate before calling

handler = workflow.run(start_event=SummarizeInputEvent(..., output_cls=output_cls))
result = await handler
if output_cls and not result.output_obj:
    raise_or_handle("engine produced no structured output; falling back to summary")

Type guard

def has_output_obj(ev: SummarizeResultEvent) -> bool:
    return isinstance(ev.output_obj, BaseModel)

Try / catch

try:
    blocks = await wf.run_summary(prompt=p, output_cls=Cls)
except ValueError as e:
    if 'No output object' in str(e):
        blocks = await wf.run_summary(prompt=p)  # retry without structured output

Prevention

When it happens

Trigger: Calling run_summary(..., output_cls=SomeBaseModel) where the underlying query engine returns a plain Response/StreamingResponse instead of PydanticResponse, or returns a PydanticResponse whose .response payload is empty/falsy. Also occurs when output_cls is not correctly propagated to the query engine so SummarizeResultEvent(summary=...) is emitted without output_obj.

Common situations: Structured-output summarization where the LLM output failed to parse into the Pydantic model; retriever returning zero nodes so the response object is empty; switching an existing summary pipeline to output_cls without enabling structured output on the LLM/query engine.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/31c73025a4a510fb. Report an issue: GitHub.