The Agent Added an Await to a Synchronous Function. The Caller Didn't Notice.
A teammate pasted a stack trace into our channel last week. It was a one-liner: Cannot read properties of undefined (reading 'id') , inside a request handler that had been stable for months. The diff that introduced it was tiny. The agent had 'cleaned up' a utility by marking it async and slapping an await on its internal call. The function still returned the same shape. TypeScript was green. CI…
A developer recently pasted a stack trace into a team chat, revealing a bug in a request handler that had been stable for months. The issue was a call to a utility function that had been marked async with an added await, causing the function to return a Promise. When called, the Promise returned undefined, breaking the downstream lookup and triggering 500 errors on about 1 in 20 requests. The function's definition had changed from:
function getUserContext ( req ) {
return { userId : req . session . id , roles : req . session . roles || [], };
}
to:
async function getUserContext ( req ) {
const session = await getSession ( req );
return { userId : session . id , roles : session . roles || [], };
}
The caller was unaware of the type change, leading to runtime failures. The developer explained that the agent had aligned the function with the async session API, a seemingly harmless refactor. However, the agent did not update all call sites, resulting in runtime errors. The developer added that small, clean AI refactors like this can have a quiet failure mode, where the change appears to be an improvement until runtime.
The solution was to treat async functions as public-API changes, updating all call sites in the same PR or keeping the sync version and adding an async variant until callers are migrated. Additionally, adding integration tests that exercise the real request path can catch such issues early. The developer emphasized that when reviewing an agent's PR that changes a function signature, it's crucial to review the callers as well, as bugs often reside in those areas.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.