Skip to content

Commit f96af17

Browse files
Document critical SDK bug with trace_async and async generators
Co-authored-by: vinicius <[email protected]>
1 parent e97f2d3 commit f96af17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CURSOR_MEMORY.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## Key Lessons Learned
44

5+
### 🚨 CRITICAL SDK BUG: trace_async Doesn't Support Async Generators
6+
7+
**STATUS**: This is a fundamental bug in the Openlayer SDK that needs immediate fixing. Users should NOT have to modify their code.
8+
9+
**The Bug**: `trace_async` decorator cannot handle async generator functions (functions that use `yield`). It tries to `await` an async generator function, which returns the generator object instead of the yielded values.
10+
11+
**Impact**:
12+
- Logs `<async_generator object>` instead of actual content
13+
- Wrong timing measurements
14+
- Breaks user expectations for streaming functions
15+
- Forces unnecessary code modifications
16+
17+
**Required Fix**: Use `inspect.isasyncgenfunction()` to detect async generators and handle them by consuming the generator while yielding values to maintain streaming behavior.
18+
519
### Duplicate Trace Issue with Async Streaming
620

721
**Problem**: When using both `@trace()` decorator and `trace_async_openai()` together, duplicate traces are generated:

0 commit comments

Comments
 (0)