next-issue 6.6.92 → 6.6.94
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/README.md +3 -1
- package/dist/agents.mjs +9 -2
- package/dist/handover.mjs +13 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -396,7 +396,9 @@ Recorded for each step: `claim`, `comments`, `reply`, `worktree`, `setup`,
|
|
|
396
396
|
command is recorded with its exit code and duration. A `tool` event holds the
|
|
397
397
|
tool name, and for a `bash` tool the command too. Each agent call adds a `usage`
|
|
398
398
|
event with the tokens, the turn count, the
|
|
399
|
-
tool-call count, the model and the session id.
|
|
399
|
+
tool-call count, the model and the session id. A call that times out, ends
|
|
400
|
+
with a model error or is stopped after its session started adds one too, and
|
|
401
|
+
its tokens count in the summary totals.
|
|
400
402
|
|
|
401
403
|
```bash
|
|
402
404
|
jq -r 'select(.kind=="usage") | [.issue,.role,.turns,.total] | @tsv' \
|
package/dist/agents.mjs
CHANGED
|
@@ -33,7 +33,14 @@ export async function runAgent(recorder, request) {
|
|
|
33
33
|
try {
|
|
34
34
|
refuseWhenStopped();
|
|
35
35
|
await session.bindExtensions({});
|
|
36
|
-
|
|
36
|
+
let result;
|
|
37
|
+
try {
|
|
38
|
+
await session.prompt(request.prompt, { expandPromptTemplates: false });
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
// A call that times out, fails or is stopped has spent tokens too.
|
|
42
|
+
result = sessionResult(recorder, request, session, started);
|
|
43
|
+
}
|
|
37
44
|
refuseWhenStopped();
|
|
38
45
|
if (timer.timedOut()) {
|
|
39
46
|
throw new Error(`The ${request.name} agent did not finish in ${request.timeoutMs} ms.`);
|
|
@@ -42,7 +49,7 @@ export async function runAgent(recorder, request) {
|
|
|
42
49
|
if (failure !== undefined) {
|
|
43
50
|
throw new Error(`The ${request.name} agent failed: ${failure}`);
|
|
44
51
|
}
|
|
45
|
-
return
|
|
52
|
+
return result;
|
|
46
53
|
}
|
|
47
54
|
finally {
|
|
48
55
|
timer.clear();
|
package/dist/handover.mjs
CHANGED
|
@@ -139,28 +139,33 @@ async function cleanUp(context, log, branch) {
|
|
|
139
139
|
log.event('worktree.error', { error: message(error) }, 'quiet');
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
async function handOver(context, log, issue, state, reason) {
|
|
142
|
+
async function handOver(context, log, issue, state, reason, earlier) {
|
|
143
143
|
const { repo, ports, config } = context;
|
|
144
144
|
log.event('hand-over', { reason }, 'quiet');
|
|
145
145
|
const { pendingHandOver: _pending, ...rest } = state;
|
|
146
|
+
let pending = earlier;
|
|
146
147
|
try {
|
|
147
|
-
|
|
148
|
-
const
|
|
148
|
+
// A retry keeps the thread time and the labelled mark of its earlier try.
|
|
149
|
+
const since = earlier?.since ?? (await threadEnd(context, issue));
|
|
150
|
+
pending = { ...earlier, reason, ...(since === undefined ? {} : { since }) };
|
|
149
151
|
await writeState(repo, { ...rest, pendingHandOver: pending });
|
|
150
152
|
await setStatus(context, issue, config.labels.needsHuman);
|
|
151
|
-
|
|
153
|
+
pending = { ...pending, labelled: true };
|
|
154
|
+
await writeState(repo, { ...rest, pendingHandOver: pending });
|
|
152
155
|
await ports.commentOnIssue(repo, issue, handOverComment(reason));
|
|
153
156
|
}
|
|
154
157
|
catch (error) {
|
|
155
|
-
throw new HandOverFailed(reason, error);
|
|
158
|
+
throw new HandOverFailed(reason, error, pending);
|
|
156
159
|
}
|
|
157
160
|
await writeState(repo, { ...rest, handedOver: true });
|
|
158
161
|
}
|
|
159
162
|
class HandOverFailed extends Error {
|
|
160
163
|
reason;
|
|
161
|
-
|
|
164
|
+
pending;
|
|
165
|
+
constructor(reason, cause, pending) {
|
|
162
166
|
super(message(cause), { cause });
|
|
163
167
|
this.reason = reason;
|
|
168
|
+
this.pending = pending;
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
function handOverReason(error, reason) {
|
|
@@ -173,7 +178,8 @@ function handOverComment(reason) {
|
|
|
173
178
|
export async function claimedError(context, log, issue, state, error, started) {
|
|
174
179
|
const { reason } = logIssueError(log, error, started);
|
|
175
180
|
try {
|
|
176
|
-
|
|
181
|
+
const earlier = error instanceof HandOverFailed ? error.pending : undefined;
|
|
182
|
+
await handOver(context, log, issue.number, state, handOverReason(error, reason), earlier);
|
|
177
183
|
}
|
|
178
184
|
catch (failure) {
|
|
179
185
|
log.event('hand-over.error', { error: message(failure) }, 'quiet');
|