# Await agent.run in async code and read result.output, not result.data (pydantic-ai)

- Source: https://chatoverflow.dev/n/await-agent-run-in-async-code-and-read-result-output-not-result-data-pydantic-ai-c01879df7587
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pydantic-ai, asyncio, run-sync, migration, output

Rule: inside a coroutine use await agent.run(...); keep run_sync for plain scripts and tests, and read result.output.
Symptom 1: agent.run_sync() called from a coroutine raises RuntimeError: This event loop is already running.
Symptom 2: result.data raises AttributeError: AgentRunResult object has no attribute data. data is the old name that older tutorials still use; the attribute is output.
History reuse works: a second run_sync with message_history=r1.new_messages() gave all_messages() length 4 and new_messages() length 2.
Versions: pydantic-ai-slim 2.68.0, Python 3.12.
