@juanbenjumea/pi-agy 0.6.1 → 0.6.2
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/CHANGELOG.md +7 -0
- package/README.md +5 -2
- package/extensions/lib/cli.ts +13 -2
- package/extensions/lib/execute.ts +83 -19
- package/package.json +1 -1
- package/skills/agy/SKILL.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
- Omit unsupported `--effort` flags for Claude thinking and Gemini variant aliases; retain effort selection for GPT-OSS.
|
|
6
|
+
- Refresh quota state after `RESOURCE_EXHAUSTED` responses and back off before retrying.
|
|
7
|
+
- Automatically fall back from an exhausted implicit quota-balanced default while preserving explicit model selections.
|
|
8
|
+
- Add regression coverage for the agy 1.2.7 model and quota behavior.
|
|
9
|
+
|
|
3
10
|
## 0.6.1
|
|
4
11
|
|
|
5
12
|
- Supersede 0.6.0, whose publish run failed: a fixed 300 ms abort in two delivery-vs-cancellation tests raced preflight on slow CI runners (the abort must land after the result arrives). The cancels are now event-driven (fired when the SUCCESS progress arrives, i.e. strictly after delivery) and tight budget margins widened 6×.
|
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ The deadline never discards finished work:
|
|
|
53
53
|
| `conversation_id` | Resume agy conversation by ID |
|
|
54
54
|
| `continue` | `--continue` most recent conversation |
|
|
55
55
|
| `new_session` | Force fresh session; set `false` to reuse last ID for dir |
|
|
56
|
-
| `effort` | Reasoning effort via `--effort`
|
|
56
|
+
| `effort` | Reasoning effort via `--effort` where supported; `gpt-oss` accepts it, while Claude thinking models reject it and Gemini aliases already encode it |
|
|
57
57
|
| `stream` | Use `stream-json` (default `true`) |
|
|
58
58
|
| `mode` | `accept-edits` by default; use `plan` for exploration/review |
|
|
59
59
|
|
|
@@ -62,7 +62,10 @@ returns it in `details.quota`/`details.quota_status` and the response when
|
|
|
62
62
|
the CLI exposes structured model records. Use the separate `agy_usage` tool
|
|
63
63
|
when choosing a model before execution. If the selected model is explicitly
|
|
64
64
|
reported as exhausted, the run stops before spending another agent turn and
|
|
65
|
-
reports the reset information.
|
|
65
|
+
reports the reset information. When no model is explicitly requested, an exhausted
|
|
66
|
+
quota-balanced default automatically falls back to the first reported available
|
|
67
|
+
model family. Explicit model selections fail clearly instead of silently
|
|
68
|
+
switching models.
|
|
66
69
|
Use `agy_usage` with `model` (for example `model=sonnet`) for a targeted
|
|
67
70
|
`available`/`exhausted`/`unknown` status. Older agy versions that do not support
|
|
68
71
|
headless `/usage` continue without failing the task. The extension requires
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -222,8 +222,17 @@ export function resolveAgyModelId(model?: AgyModel, tier?: AgyOptions["tier"]):
|
|
|
222
222
|
return modelCatalog[alias] ?? MODEL_MAP[alias];
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Gemini aliases already select a low/medium/high model variant. Claude's
|
|
227
|
+
* thinking models also reject --effort; keep the flag for model families that
|
|
228
|
+
* expose it without turning a valid tool call into an argument error.
|
|
229
|
+
*/
|
|
230
|
+
export function supportsAgyEffort(model?: AgyModel, tier?: AgyOptions["tier"]): boolean {
|
|
231
|
+
return resolveAgyModelId(model, tier).startsWith("gpt-oss-");
|
|
232
|
+
}
|
|
233
|
+
|
|
225
234
|
const TRANSIENT_FAILURE_PATTERN =
|
|
226
|
-
/rate.?limit|429|overloaded|temporarily unavailable|network|connection (reset|refused)|econnreset|etimedout|socket hang up|\b50[023]\b/i;
|
|
235
|
+
/rate.?limit|resource[_ -]?exhausted|429|overloaded|temporarily unavailable|network|connection (reset|refused)|econnreset|etimedout|socket hang up|\b50[023]\b/i;
|
|
227
236
|
|
|
228
237
|
/** Heuristic for transient agy failures that are safe to retry once. */
|
|
229
238
|
export function isTransientAgyFailure(message: string): boolean {
|
|
@@ -254,7 +263,9 @@ export function buildAgyArgs(options: AgyOptions): string[] {
|
|
|
254
263
|
"--disable-slash-commands",
|
|
255
264
|
...(mode === "sandbox" ? ["--sandbox"] : ["--mode", mode]),
|
|
256
265
|
...(writes && skipPermissions ? ["--dangerously-skip-permissions"] : []),
|
|
257
|
-
...(options.effort
|
|
266
|
+
...(options.effort && supportsAgyEffort(options.model, options.tier)
|
|
267
|
+
? ["--effort", options.effort]
|
|
268
|
+
: []),
|
|
258
269
|
];
|
|
259
270
|
|
|
260
271
|
if (options.continue) {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
summarizeGitDiffSince,
|
|
24
24
|
type GitBaseline,
|
|
25
25
|
} from "./postflight.js";
|
|
26
|
-
import { runPreflight } from "./preflight.js";
|
|
26
|
+
import { resetPreflightCache, runPreflight } from "./preflight.js";
|
|
27
27
|
import { getSession, saveSession, conversationSummary } from "./sessions.js";
|
|
28
28
|
|
|
29
29
|
export type AgyMode = "plan" | "accept-edits" | "sandbox";
|
|
@@ -86,9 +86,11 @@ export async function executeAgyTask(
|
|
|
86
86
|
const config = await loadAgyConfig(undefined, abortSignal);
|
|
87
87
|
// Explicit model → legacy tier → configured default → flash-medium.
|
|
88
88
|
const selectedModel = resolveAgyModelAlias(options.model, options.tier);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
effectiveModel = model
|
|
89
|
+
const resolvedModel = selectedModel ?? (await resolveDefaultModel(config, abortSignal));
|
|
90
|
+
let model: AgyModel = resolvedModel ?? "flash-medium";
|
|
91
|
+
effectiveModel = model;
|
|
92
|
+
const autoModelSelection =
|
|
93
|
+
!selectedModel && !config.defaultModel && !config.defaultModelCommand;
|
|
92
94
|
const skipPermissions = config.skipPermissions !== false;
|
|
93
95
|
|
|
94
96
|
return await withDirLock(
|
|
@@ -143,20 +145,31 @@ export async function executeAgyTask(
|
|
|
143
145
|
const quotaSummary = quota ? formatAgyUsage(quota, selectedModelId) : undefined;
|
|
144
146
|
if (quotaSummary) onProgress?.(quotaSummary);
|
|
145
147
|
if (selectedQuotas.some((entry) => isAgyQuotaExhausted(entry))) {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.every((entry) => !isAgyQuotaExhausted(entry)),
|
|
148
|
+
const fallback = autoModelSelection
|
|
149
|
+
? findAvailableFallbackModel(quota, model)
|
|
150
|
+
: undefined;
|
|
151
|
+
if (fallback) {
|
|
152
|
+
onProgress?.(
|
|
153
|
+
`agy: ${selectedModelId} quota exhausted; falling back to ${resolveAgyModelId(fallback)}…`,
|
|
153
154
|
);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
model = fallback;
|
|
156
|
+
effectiveModel = fallback;
|
|
157
|
+
} else {
|
|
158
|
+
const quotaEntries = quota?.models ?? [];
|
|
159
|
+
const alternatives = [...new Set(quotaEntries.map((entry) => entry.model))]
|
|
160
|
+
.filter((candidate) => candidate.toLowerCase() !== selectedModelId.toLowerCase())
|
|
161
|
+
.filter((candidate) =>
|
|
162
|
+
quotaEntries
|
|
163
|
+
.filter((entry) => entry.model === candidate)
|
|
164
|
+
.every((entry) => !isAgyQuotaExhausted(entry)),
|
|
165
|
+
);
|
|
166
|
+
const alternativeText = alternatives.length
|
|
167
|
+
? ` Available reported alternatives: ${alternatives.join(", ")}.`
|
|
168
|
+
: " No available alternative was reported.";
|
|
169
|
+
throw new Error(
|
|
170
|
+
`agy quota exhausted for ${selectedModelId}; choose another model or run agy_usage first.${alternativeText}\n${quotaSummary ?? ""}`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
160
173
|
}
|
|
161
174
|
const runTimeoutMs = remainingBudget(startedAt, options.timeout_ms);
|
|
162
175
|
// Emitted via onProgress directly: progress tracking (and therefore
|
|
@@ -181,7 +194,7 @@ export async function executeAgyTask(
|
|
|
181
194
|
abortSignal,
|
|
182
195
|
trackProgress,
|
|
183
196
|
);
|
|
184
|
-
}, onProgress);
|
|
197
|
+
}, onProgress, abortSignal);
|
|
185
198
|
|
|
186
199
|
if (run.conversation_id) {
|
|
187
200
|
try {
|
|
@@ -295,6 +308,29 @@ function remainingBudget(startedAt: number, timeoutMs: number): number {
|
|
|
295
308
|
return remaining;
|
|
296
309
|
}
|
|
297
310
|
|
|
311
|
+
const FALLBACK_MODELS: readonly AgyModel[] = [
|
|
312
|
+
"flash-medium",
|
|
313
|
+
"flash-low",
|
|
314
|
+
"flash-high",
|
|
315
|
+
"pro-low",
|
|
316
|
+
"pro-high",
|
|
317
|
+
"gpt-oss",
|
|
318
|
+
"sonnet",
|
|
319
|
+
"opus",
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
function findAvailableFallbackModel(
|
|
323
|
+
snapshot: AgyUsageSnapshot | undefined,
|
|
324
|
+
current: AgyModel,
|
|
325
|
+
): AgyModel | undefined {
|
|
326
|
+
if (!snapshot) return undefined;
|
|
327
|
+
return FALLBACK_MODELS.find((candidate) => {
|
|
328
|
+
if (candidate === current) return false;
|
|
329
|
+
const entries = findAgyQuotaEntries(snapshot, resolveAgyModelId(candidate));
|
|
330
|
+
return entries.length > 0 && entries.every((entry) => !isAgyQuotaExhausted(entry));
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
298
334
|
/**
|
|
299
335
|
* Retry once when agy fails before emitting any activity (tool step or model
|
|
300
336
|
* response) with a transient error (rate limit, network blip). Zero activity
|
|
@@ -303,6 +339,7 @@ function remainingBudget(startedAt: number, timeoutMs: number): number {
|
|
|
303
339
|
async function runWithTransientRetry<T>(
|
|
304
340
|
attempt: (trackProgress: (message: string) => void) => Promise<T>,
|
|
305
341
|
onProgress?: (message: string) => void,
|
|
342
|
+
signal?: AbortSignal,
|
|
306
343
|
): Promise<T> {
|
|
307
344
|
for (let tries = 0; ; tries++) {
|
|
308
345
|
let sawActivity = false;
|
|
@@ -320,10 +357,37 @@ async function runWithTransientRetry<T>(
|
|
|
320
357
|
isTransientAgyFailure(message) &&
|
|
321
358
|
!/\b(?:ETIMEDOUT|timed out)\b/i.test(message)
|
|
322
359
|
) {
|
|
323
|
-
|
|
360
|
+
const quotaMayHaveChanged = /resource[_ -]?exhausted|429/i.test(message);
|
|
361
|
+
if (quotaMayHaveChanged) resetPreflightCache();
|
|
362
|
+
onProgress?.(
|
|
363
|
+
quotaMayHaveChanged
|
|
364
|
+
? "agy: quota request was rejected before any work — refreshing quota and retrying once…"
|
|
365
|
+
: "agy: transient failure before any work — retrying once…",
|
|
366
|
+
);
|
|
367
|
+
await delayBeforeRetry(signal);
|
|
324
368
|
continue;
|
|
325
369
|
}
|
|
326
370
|
throw error;
|
|
327
371
|
}
|
|
328
372
|
}
|
|
329
373
|
}
|
|
374
|
+
|
|
375
|
+
function delayBeforeRetry(signal?: AbortSignal): Promise<void> {
|
|
376
|
+
return new Promise((resolve, reject) => {
|
|
377
|
+
const timer = setTimeout(resolve, 1_000);
|
|
378
|
+
if (!signal) return;
|
|
379
|
+
if (signal.aborted) {
|
|
380
|
+
clearTimeout(timer);
|
|
381
|
+
reject(signal.reason ?? new Error("agy retry cancelled"));
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
signal.addEventListener(
|
|
385
|
+
"abort",
|
|
386
|
+
() => {
|
|
387
|
+
clearTimeout(timer);
|
|
388
|
+
reject(signal.reason ?? new Error("agy retry cancelled"));
|
|
389
|
+
},
|
|
390
|
+
{ once: true },
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanbenjumea/pi-agy",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Enhanced Antigravity CLI (agy) bridge for Pi — streaming progress, conversation continuity, repo-aware verify, and diff summaries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/skills/agy/SKILL.md
CHANGED
|
@@ -65,13 +65,13 @@ agy_usage
|
|
|
65
65
|
- Escalate within the Gemini quota group to `pro-low` or `pro-high` only when needed.
|
|
66
66
|
- Use `sonnet` for normal Claude-group coding/review; reserve `opus` for the hardest architecture or root-cause work.
|
|
67
67
|
- Use `gpt-oss` when an open-model alternative is specifically desired.
|
|
68
|
-
- Set `effort`
|
|
68
|
+
- Set `effort` only for `gpt-oss`; Claude thinking models reject `--effort`, and Gemini aliases encode effort in the model id.
|
|
69
69
|
- For consequential work, have one family produce and the opposite family review with `mode=plan`; do not spend both groups on trivial tasks.
|
|
70
70
|
- Batch related work, avoid parallel calls within one shared-quota group or directory, and use `digest=true` (default) for non-write tasks.
|
|
71
71
|
|
|
72
72
|
## Enhancements over upstream pi-agy
|
|
73
73
|
|
|
74
|
-
- **Quota discovery** — `agy_usage` and `/agy usage` report model-specific remaining quota and reset times; executions refresh quota snapshots and return machine-readable `quota_status` as well.
|
|
74
|
+
- **Quota discovery** — `agy_usage` and `/agy usage` report model-specific remaining quota and reset times; executions refresh quota snapshots, automatically fall back when an implicit default is exhausted, and return machine-readable `quota_status` as well.
|
|
75
75
|
- **Streaming progress** — live tool steps via `stream-json` and Pi `onUpdate`.
|
|
76
76
|
- **Conversation continuity** — `conversation_id`, `continue`, session store under `$PI_CODING_AGENT_DIR/agy-sessions.json` (or `~/.pi/agent/agy-sessions.json` by default) with one-line task summaries; runs that time out or are cancelled are recorded too and stay resumable, and the `agy_history` tool lets agents list past conversations.
|
|
77
77
|
- **Repo-aware verify** — prefers `just ci` when a justfile defines `ci:`.
|