fix(pi): move delivery flushing into the daemon - #80
Conversation
Pi waited for backend delivery at lifecycle boundaries. A slow flush
blocked the next input for 10+ seconds and could time out.
Before:
Pi -> journal ack -> wait for backend flush -> next input
After:
Pi -> journal ack -> next input
|
+-> daemon flushes to Braintrust in the background
Keep ordered capture acknowledgement, but let the daemon flush turns,
compaction, tree changes, and shutdown, as it does for Codex/Claude.
Retry attempts keep the turn open. Delivery continues after Pi disconnects.
Requires both the updated Pi extension and bt daemon.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
When Pi submits the next turn immediately after agent_end, that event may already be waiting in the ingress queue. Because the flush is started in an independently scheduled task, the ingress worker can enqueue before_agent_start and subsequent events into the session actor before flush_source_session enqueues its SessionMsg::Flush. The supposed turn-boundary flush can therefore checkpoint part of the next turn and be delayed behind arbitrary later traffic. Queue the flush message in actor order before processing the next ingress event, while leaving delivery itself asynchronous.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e5aeb16222
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
resolves https://linear.app/braintrustdata/issue/SDK-376
Pi waited for backend delivery at lifecycle boundaries. A slow flush blocked the next input for 10+ seconds and could time out.
Before:
After:
Keep ordered capture acknowledgement, but let the daemon flush turns, compaction, tree changes, and shutdown, as it does for Codex/Claude. Retry attempts keep the turn open. Delivery continues after Pi disconnects.