Investigate user session logging failures
📥 Pull Request
📘 Description Resolves an issue where AgentOps sessions appeared to initialize (URL logged) but no data was received by the backend. This was due to an authentication race condition where spans were exported before the JWT token was available.
The fix introduces:
- Synchronization to ensure authentication completes before allowing span exports.
- New
wait_for_auth(defaultTrue) andauth_timeoutconfiguration options. - Improved exporter logic to handle pending authentication and enhance error logging.
🧪 Testing
Validated the fix by creating test_auth_fix.py, which tests:
- Session initialization with
wait_for_authenabled (default behavior). - Session initialization with
wait_for_authdisabled (previous behavior). - Session initialization without an API key.
Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents
Codecov Report
:x: Patch coverage is 55.26316% with 17 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| agentops/client/client.py | 42.85% | 12 Missing :warning: |
| agentops/sdk/exporters.py | 66.66% | 3 Missing :warning: |
| agentops/config.py | 75.00% | 2 Missing :warning: |
:loudspeaker: Thoughts on this report? Let us know!
This pull request has been automatically marked as stale because it has not had any activity in the last 14 days.
If no updates are made within 7 days, this PR will be automatically closed.