Repository navigation
Commit 854ff4c
fix(pi-extension): replay offline backlog through the batch endpoint (#4692)
* fix(pi-extension): replay offline backlog through the batch endpoint
After a server outage pi's local pending queue can hold hundreds of
addMessage entries. The takeover barrier requires that queue to be empty
for the session, but replayed it with the shared replayPending(): one
POST per entry, at most one replay window (50) per attempt. At the
~0.67s/entry measured in #4504 a 670-entry backlog needed 14 takeover
attempts of ~33s each, and pendingTokens kept growing meanwhile.
- flushForTakeover drains the session's backlog via
/messages/batch (sendSessionMessages, BATCH_LIMIT=100), so the whole
backlog clears in a handful of requests within one attempt. Entries
are claimed one batch at a time; a failed batch costs a retry only for
the entries it contained, the rest stay untouched.
- syncBranch sends the whole turn in one batch request instead of one
POST per payload, with retryable failures queued as before.
- pi's shared dir now vendors batch-send.mjs (already used by the
claude-code, codex, opencode and zcode plugins).
Fixes #4504
Co-Authored-By: ktz03 <[email protected]>
Co-Authored-By: jiale li <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Uued6mAGJ4jfTW4XRmNWwL
* fix(pi-extension): enqueue non-retryable batch failures and bound drain (#4702)
Address #4692 review nits from now-ing and jiale-li-orion:
- enqueueRemainder always queues on enqueue-on-failure (incl. 400/403) so the sync watermark advances
- drainSessionBacklog soft-bounded by OPENVIKING_PENDING_DRAIN_BUDGET_MS / MAX_BATCHES
- tests for watermark enqueue and maxBatches stop
* fix(pi-extension): keep batch-send drop policy, advance watermark in pi
#4702 made sendSessionMessages enqueue payloads after a non-retryable
rejection so pi's sync watermark would advance. That reverses a policy
pinned by the shared batch-send tests (poison payloads are dropped, not
queued) for every harness, and the other vendored copies were not
regenerated.
Keep the shared policy and fix the watermark where the need is: pi's
sendPayloads counts non-retryable drops as accepted, matching the
outcome replayPending() applies to such entries.
Co-Authored-By: ktz03 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Uued6mAGJ4jfTW4XRmNWwL
---------
Co-authored-by: ktz03 <[email protected]>
Co-authored-by: jiale li <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>1 parent 37db9c8 commit 854ff4c
6 files changed
Lines changed: 373 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
69 | 148 | | |
70 | 149 | | |
71 | 150 | | |
72 | 151 | | |
73 | 152 | | |
74 | | - | |
| 153 | + | |
| 154 | + | |
75 | 155 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 156 | + | |
81 | 157 | | |
82 | | - | |
83 | 158 | | |
| 159 | + | |
84 | 160 | | |
85 | 161 | | |
86 | 162 | | |
| |||
91 | 167 | | |
92 | 168 | | |
93 | 169 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
99 | 200 | | |
100 | 201 | | |
101 | 202 | | |
| |||
0 commit comments