opencode-azure-devops-pr-review 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/session.mjs CHANGED
@@ -165,15 +165,18 @@ export function restartIndex(texts) {
165
165
 
166
166
  /**
167
167
  * Classify a failed stage for the runtime's retry policy.
168
- * - overflow: the host tried to compact (context full) or the provider rejected size.
168
+ * - overflow: the host attempted compaction in the failed turn (context full) or
169
+ * the provider rejected size. A refused background summary
170
+ * (`experimental.background_compaction`) is not evidence: the turn went on, so
171
+ * its own failure decides.
169
172
  * - transient: interrupted streams, provider 408/409/425/429/5xx, missing idle,
170
173
  * unexpected host messages.
171
174
  * - permanent: everything else (authentication, bad request, a used-up quota or
172
175
  * free-model limit, whatever its HTTP status, cancellation).
173
176
  */
174
- export function classifyFailure(error, { compactionRequested = false } = {}) {
175
- if (compactionRequested) return 'overflow';
177
+ export function classifyFailure(error) {
176
178
  const execution = error?.execution;
179
+ if (execution?.compaction) return 'overflow';
177
180
  if (execution?.interrupted || execution?.provider?.exhausted) return 'permanent';
178
181
  const status = execution?.provider?.status;
179
182
  if (status === 413) return 'overflow';
@@ -231,6 +234,10 @@ export async function requestReview(context, { sessionID, text, role, model, met
231
234
  terminalOutcome: terminal?.type === 'idle' ? outcome(terminal.outcome) : 'missing-idle',
232
235
  assistantResponses: assistants.length, lastFinish: finish,
233
236
  interrupted: session.outcome === 'interrupted' || terminal?.outcome === 'interrupted' || final?.error?.type === 'aborted' };
237
+ // OpenCode opens a compaction's message before it asks for the summary, so a compaction it attempted in this
238
+ // turn, which AZPR refuses, shows here. A background summary (OpenCode 2.1.4) publishes nothing.
239
+ const compaction = turn.filter(message => message?.type === 'compaction').at(-1);
240
+ if (compaction) execution.compaction = ['running', 'completed', 'failed'].includes(compaction.status) ? compaction.status : 'unknown';
234
241
  const provider = !execution.interrupted && providerFailure(final, assistants);
235
242
  if (provider) execution.provider = provider;
236
243
  const hint = provider?.exhausted