# Response cache tells same-named output schemas apart

> Agno's model response cache no longer hands an agent the cached JSON of a different Pydantic output_schema that happens to share its class name.

- Published: 2026-10-08
- Author: Charan Rathore
- Categories: Changelog
- Canonical: https://www.agno.com/blog/response-cache-tells-same-named-output-schemas-apart
- Markdown: https://www.agno.com/blog/response-cache-tells-same-named-output-schemas-apart.md

Agno's `Model._get_model_cache_key()` now turns a Pydantic `response_format` class into its `model_json_schema()`, nested field definitions included. Earlier releases used the class name, so two `Output` classes in different modules collided whenever the prompt matched.

With `cache_response=True`, the second agent got the first agent's cached JSON. We gave two agents one `OpenAIChat` with `cache_response=True`, pointed it at a mocked endpoint that answers whichever schema it receives, and asked both the same question. One `output_schema` was `Output` with a `total: float` field, the other `Output` with `priority: str`.

```text
# Before (real output)
cache keys equal: True
Output(total): Output(total=42.0)
WARNING Failed to parse cleaned JSON: 1 validation error for Output
priority
  Field required [type=missing, input_value={'total': 42.0}, input_type=dict]
WARNING Failed to convert response to output_schema
Output(priority): '{"total": 42.0}'
requests sent to the provider: 1

# Now (real output)
cache keys equal: False
Output(total): Output(total=42.0)
Output(priority): Output(priority='high')
requests sent to the provider: 2
```

Classes with identical schemas still share an entry. A model with no JSON schema, such as one with a `Callable` field, falls back to its module and qualified name.

See the [cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/02_agents/14_advanced/cache_model_response.py), and learn more about [response caching](https://docs.agno.com/models/cache-response) in the documentation.
