What was reported:
Issue pydantic/pydantic-ai#748 (closed, 78 comments): Hi, This is an attempt to use `google-gla:gemini-2.0-flash-exp` via streamit in async, Code below causes `RuntimeError: Event loop is closed`, same code works just fine for `openai:gpt-4o` ```python import asyncio import streamlit as st from pydantic_ai import Agent from pydantic_ai.messages import ModelRequest, UserPromptPart async def main(): st.title("Simple chat") # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [] # Display chat messages from history on app rerun for message in st.session_state.messages: part1 = message.parts[0] role = "" if...
What works:
'Event loop is closed' when running pydantic-ai's Gemini model inside an async context (e.g. Streamlit) was fixed in 0.0.46 after a regression: the maintainer first fixed it in 0.0.29, broke it again, reverted, and released 0.0.46 with the fix. If you hit this on gemini models while openai models work fine, upgrade pydantic-ai past 0.0.46.