next-issue 6.6.91 → 6.6.93

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 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' \
@@ -595,7 +597,10 @@ that still has the label is not claimed, unless it has an answer to the
595
597
  hand-over: then the run claims it and takes the label off. When the label of a
596
598
  hand-over reaches GitHub but its comment does not, an answer to an earlier
597
599
  hand-over does not count: the issue waits, and the worker lists it, until a
598
- person takes the label off or a writer comments after that hand-over.
600
+ person takes the label off or a writer comments after that hand-over. Either
601
+ way, the next run that claims it counts it as a hand-over: it puts the budgets
602
+ and the findings back to zero and passes on the comments posted after it. When
603
+ the label edit itself fails, the next run keeps the budgets and the findings.
599
604
 
600
605
  To give guidance, answer the hand-over with a comment on the issue. When the run
601
606
  resumes the issue, it reads the comments posted after its last
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
- await session.prompt(request.prompt, { expandPromptTemplates: false });
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 sessionResult(recorder, request, session, started);
52
+ return result;
46
53
  }
47
54
  finally {
48
55
  timer.clear();
package/dist/handover.mjs CHANGED
@@ -145,11 +145,10 @@ async function handOver(context, log, issue, state, reason) {
145
145
  const { pendingHandOver: _pending, ...rest } = state;
146
146
  try {
147
147
  const since = await threadEnd(context, issue);
148
- await writeState(repo, {
149
- ...rest,
150
- pendingHandOver: { reason, ...(since === undefined ? {} : { since }) },
151
- });
148
+ const pending = { reason, ...(since === undefined ? {} : { since }) };
149
+ await writeState(repo, { ...rest, pendingHandOver: pending });
152
150
  await setStatus(context, issue, config.labels.needsHuman);
151
+ await writeState(repo, { ...rest, pendingHandOver: { ...pending, labelled: true } });
153
152
  await ports.commentOnIssue(repo, issue, handOverComment(reason));
154
153
  }
155
154
  catch (error) {
package/dist/pipeline.mjs CHANGED
@@ -47,12 +47,17 @@ export async function processIssue(context, issue, claimed = () => undefined) {
47
47
  log.event('issue.end', { outcome: report.outcome, reason: report.reason, ms: report.ms }, 'quiet');
48
48
  return report;
49
49
  }
50
- /** A hand-over whose comment failed counts once the issue is claimed with its label still on, that is with an answer. */
50
+ /**
51
+ * A hand-over whose comment failed counts once its label reached GitHub (a person who takes it off retries),
52
+ * or once the issue is claimed with its label still on, that is with an answer.
53
+ */
51
54
  function wasHandedOver(context, issue, saved) {
52
55
  if (saved?.handedOver === true) {
53
56
  return true;
54
57
  }
55
- return (saved?.pendingHandOver !== undefined && hasLabel(issue.labels, context.config.labels.needsHuman));
58
+ const pending = saved?.pendingHandOver;
59
+ return (pending !== undefined &&
60
+ (pending.labelled === true || hasLabel(issue.labels, context.config.labels.needsHuman)));
56
61
  }
57
62
  function startState(context, issue, saved, handedOver) {
58
63
  if (saved === undefined) {
package/dist/state.mjs CHANGED
@@ -46,7 +46,10 @@ function isReviewRound(value) {
46
46
  isOptional(value.settled, 'string'));
47
47
  }
48
48
  function isPending(value) {
49
- return isRecord(value) && typeof value.reason === 'string' && isOptional(value.since, 'string');
49
+ return (isRecord(value) &&
50
+ typeof value.reason === 'string' &&
51
+ isOptional(value.since, 'string') &&
52
+ isOptional(value.labelled, 'boolean'));
50
53
  }
51
54
  function isState(value) {
52
55
  return (isRecord(value) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.91",
3
+ "version": "6.6.93",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",