SQLAlchemy patterns — engine setup, session management, declarative models,
98
99%
Does it follow best practices?
Impact
98%
1.96xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively uses async SQLAlchemy patterns correctly -- async engine, async session, proper pool config, Mapped types, and eager loading -- when building a FastAPI notification service. The task says 'async' and 'FastAPI' but does not prescribe specific SQLAlchemy configuration.",
"type": "weighted_checklist",
"checklist": [
{
"name": "create_async_engine used (not sync)",
"description": "Uses create_async_engine with an async driver (asyncpg or aiosqlite), not the sync create_engine which would block the event loop.",
"max_score": 14
},
{
"name": "async_sessionmaker used (not sync sessionmaker)",
"description": "Uses async_sessionmaker to create the session factory, not sync sessionmaker.",
"max_score": 12
},
{
"name": "expire_on_commit=False on async sessionmaker",
"description": "async_sessionmaker configured with expire_on_commit=False. The agent was NOT warned about this pitfall.",
"max_score": 10
},
{
"name": "pool_pre_ping enabled",
"description": "Async engine created with pool_pre_ping=True.",
"max_score": 8
},
{
"name": "Pool size and overflow configured",
"description": "Async engine specifies pool_size, max_overflow, and pool_recycle.",
"max_score": 8
},
{
"name": "Mapped types used (not Column)",
"description": "Models use Mapped[type] = mapped_column(...), not legacy Column().",
"max_score": 10
},
{
"name": "select() API used (not query())",
"description": "Queries use select() with session.execute(), not legacy session.query().",
"max_score": 8
},
{
"name": "back_populates used (not backref)",
"description": "User-Notification relationship uses back_populates.",
"max_score": 6
},
{
"name": "cascade='all, delete-orphan' on User.notifications",
"description": "User.notifications relationship uses cascade='all, delete-orphan'. The agent was NOT told about cascade rules.",
"max_score": 8
},
{
"name": "Database URL from environment",
"description": "Database URL read from environment variable, not hardcoded.",
"max_score": 6
},
{
"name": "Async session dependency uses async with",
"description": "The FastAPI dependency uses 'async with AsyncSessionLocal() as session' or equivalent async context manager pattern for proper cleanup.",
"max_score": 10
}
]
}