# Structured output parsing handles a scalar before a list

> Agno's parse_response_model_str now returns your output_schema when one JSON fragment in a model's answer gives a list field a scalar and a later fragment gives it the list.

- Published: 2026-10-01
- Author: inchang-ing
- Categories: Changelog
- Canonical: https://www.agno.com/blog/structured-output-parsing-handles-a-scalar-before-a-list
- Markdown: https://www.agno.com/blog/structured-output-parsing-handles-a-scalar-before-a-list.md

When a model's text answer holds several JSON objects, Agno's `parse_response_model_str` merges them field by field: list fields collect items and other fields keep the last value. The list branch extended whatever was already stored, so an earlier fragment that gave the field a string, a number, `None` or an object raised `AttributeError` from inside the parser. Agent and team runs call this parser for an `output_schema` when the model returns a string, and models often write a draft value before the real list.

The parser now starts a fresh list whenever the stored value isn't one:

```python
from typing import List

from pydantic import BaseModel

from agno.utils.string import parse_response_model_str

class Todo(BaseModel):
    items: List[str]

content = '{"items": "draft"}\n{"items": ["buy milk", "ship release"]}'
parse_response_model_str(content, Todo)
# Before: AttributeError 'str' object has no attribute 'extend'
# Now:    Todo(items=['buy milk', 'ship release'])
```

See the [cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/02_agents/02_input_output/output_schema.py), and learn more about [structured output](https://docs.agno.com/input-output/structured-output/agent) in the documentation.
