Repository navigation
[openai] Page audit logs with after and move the cursor after the last page - #22733
vatsaldesai93 wants to merge 6 commits into
Conversation
The audit program set last_timestamp from the first page of a window, before the older pages were read. If a later page failed, or the agent restarted, the next window started at that timestamp and the remaining pages were never collected. The failed run also left next.before_cursor in state, so the next window was requested with a stale page cursor. Keep the newest timestamp in state until the last page and only then move the cursor, and drop the page cursor when a new window starts. Events read again after an interruption have the same _id.
ReviewersBuildkite doesn't run automatically for external contributions. To start one, a
Commenting NOTE: https://github.com/elastic/integrations/blob/main/.buildkite/pull-requests.json contains all those details. |
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical cursor-persistence issue can permanently skip unread events if pagination fails or the agent restarts during the first collection.
1 open issue
What changed in this PR
This PR updates the OpenAI integration’s audit-log pagination to use after and defer timestamp advancement until the final page, aiming to prevent skipped events after interrupted collection.
Changes:
- Switch pagination to
afterand clear stale paging state when starting a new window. - Add a regression script for a second-page failure and update the existing mock.
- Bump the package to 2.4.1 and document the fix.
| File | Description |
|---|---|
packages/openai/manifest.yml |
Bumps the package version to 2.4.1. |
packages/openai/data_stream/audit/agent/stream/cel.yml.hbs |
Updates pagination and defers timestamp cursor advancement. |
packages/openai/data_stream/audit/_dev/test/scripts/interrupted_paging.txt |
Adds interrupted-pagination regression coverage. |
packages/openai/changelog.yml |
Documents the pagination bug fix. |
packages/openai/_dev/deploy/docker/files/config.yml |
Updates the mock to match the after parameter. |
Review effort: Balanced

Proposed commit message
How to test
elastic-package test script -C packages/openai -d auditThe second page fails once. The test expects 4 events and 1 error. Without the fix it stops at 3 documents.
Notes
after=last_id(openai/pagination.py,ConversationCursorPage).