typeclaw 0.47.0 → 0.47.1
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/package.json +1 -1
- package/src/agent/git-nudge.ts +4 -12
- package/src/agent/session-origin.ts +8 -6
- package/src/agent/tools/channel-reply.ts +13 -13
- package/src/agent/tools/channel-send.ts +3 -3
- package/src/bundled-plugins/guard/policies/uncommitted-changes.ts +4 -11
- package/src/bundled-plugins/memory/dreaming.ts +26 -66
- package/src/channels/continuation-willingness.ts +2 -2
- package/src/channels/github-false-receipt.ts +4 -4
- package/src/channels/github-rereview-guard.ts +8 -8
- package/src/channels/router.ts +178 -58
- package/src/git/run.ts +60 -0
- package/src/skills/typeclaw-channel-github/SKILL.md +4 -4
package/package.json
CHANGED
package/src/agent/git-nudge.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hooklessGitArgs } from '@/git/hookless'
|
|
2
1
|
import { resolveAgentGit } from '@/git/resolve-agent-git'
|
|
2
|
+
import { runGit } from '@/git/run'
|
|
3
3
|
|
|
4
4
|
const MAX_LISTED_PATHS = 10
|
|
5
5
|
|
|
@@ -65,22 +65,14 @@ function filterAgentOwned(paths: readonly string[]): string[] {
|
|
|
65
65
|
return paths.filter((p) => !RUNTIME_OWNED_PREFIXES.some((prefix) => p.startsWith(prefix)))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// Mirrors the spawn pattern in `src/container/start.ts` `commitSystemFile`.
|
|
69
68
|
const defaultDeps: GitNudgeDeps = {
|
|
70
69
|
async readStatus(agentDir, gitArgs) {
|
|
71
70
|
const bun = getBun()
|
|
72
71
|
if (!bun) return null
|
|
73
72
|
try {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
stdout: 'pipe',
|
|
78
|
-
stderr: 'pipe',
|
|
79
|
-
})
|
|
80
|
-
const exit = await proc.exited
|
|
81
|
-
if (exit !== 0) return null
|
|
82
|
-
const text = await new Response(proc.stdout).text()
|
|
83
|
-
return parsePorcelain(text)
|
|
73
|
+
const { exitCode, stdout } = await runGit(bun, agentDir, [...gitArgs, 'status', '--porcelain=v1'])
|
|
74
|
+
if (exitCode !== 0) return null
|
|
75
|
+
return parsePorcelain(stdout)
|
|
84
76
|
} catch {
|
|
85
77
|
return null
|
|
86
78
|
}
|
|
@@ -486,15 +486,17 @@ function renderChannelOrigin(
|
|
|
486
486
|
...(origin.adapter === 'github'
|
|
487
487
|
? [
|
|
488
488
|
'tool call, keep working and post the answer with a single final',
|
|
489
|
-
'`channel_reply
|
|
489
|
+
'`channel_reply({ text, more_work_this_turn: false })`.',
|
|
490
|
+
'Do not post an "On it" ack comment first — the runtime',
|
|
490
491
|
'already added an :eyes: reaction; use `channel_react` for explicit ack.',
|
|
491
492
|
]
|
|
492
493
|
: [
|
|
493
494
|
'tool call, send a one-line ack first via `channel_reply({ text: "On it.",',
|
|
494
|
-
'
|
|
495
|
-
'`channel_reply
|
|
496
|
-
'
|
|
497
|
-
'the ack
|
|
495
|
+
'more_work_this_turn: true })`, keep working, then send the answer with a',
|
|
496
|
+
'final `channel_reply({ text, more_work_this_turn: false })`.',
|
|
497
|
+
'The ack is not your reply; the answer is. Once the answer lands, end your turn.',
|
|
498
|
+
'`more_work_this_turn: true` is mandatory on the ack or the turn ends there',
|
|
499
|
+
'and drops the fetch/subagent/actual answer.',
|
|
498
500
|
]),
|
|
499
501
|
'',
|
|
500
502
|
'**Backgrounded work does not end the obligation.** If you spawn a',
|
|
@@ -508,7 +510,7 @@ function renderChannelOrigin(
|
|
|
508
510
|
'',
|
|
509
511
|
'Do not send a second reply just to rephrase, restate, or "confirm" what you already said.',
|
|
510
512
|
'',
|
|
511
|
-
'To reply here, call `channel_reply({ text })`. Addressing (including the',
|
|
513
|
+
'To reply here, call `channel_reply({ text, more_work_this_turn })`. Addressing (including the',
|
|
512
514
|
`thread${origin.thread !== null ? '' : ' — none here, this is a channel-root session'}) is filled in; you don't need`,
|
|
513
515
|
'to copy these fields:',
|
|
514
516
|
'',
|
|
@@ -83,17 +83,17 @@ export function createChannelReplyTool({
|
|
|
83
83
|
},
|
|
84
84
|
),
|
|
85
85
|
),
|
|
86
|
-
|
|
86
|
+
more_work_this_turn: Type.Boolean({
|
|
87
87
|
description:
|
|
88
|
-
'REQUIRED on every channel_reply — you must explicitly choose, there is no default. Set `true` when this reply is a mid-turn status update (e.g. "working on it…") and you still have
|
|
88
|
+
'REQUIRED on every channel_reply — you must explicitly choose, there is no default. Set `true` when this reply is a mid-turn status update (e.g. "working on it…") and you still have MORE WORK to do THIS turn — fetching data, running a tool, spawning a subagent, then replying again; `true` keeps the turn alive so that follow-up actually runs. ' +
|
|
89
89
|
'Set `false` when this reply is your final message for the turn (the common case). ' +
|
|
90
|
-
'This choice is mandatory precisely because a missing value used to default to ending the turn silently: a successful reply ends the turn unless `
|
|
90
|
+
'This choice is mandatory precisely because a missing value used to default to ending the turn silently: a successful reply ends the turn unless `more_work_this_turn` is `true`, so a `false` on an ack you meant to keep working from drops the work you promised. ' +
|
|
91
91
|
'Do not set `true` just to seem responsive; only when genuine multi-step work follows in the same turn.',
|
|
92
92
|
}),
|
|
93
93
|
resolve_review_thread: Type.Optional(
|
|
94
94
|
Type.Boolean({
|
|
95
95
|
description:
|
|
96
|
-
'GitHub PR review threads ONLY. On a TERMINAL (`
|
|
96
|
+
'GitHub PR review threads ONLY. On a TERMINAL (`more_work_this_turn:false`) github PR review-thread reply that carries `text`, this is REQUIRED: you must set it to `true` or `false` and omitting it is rejected — you will be told to re-call with an explicit choice. (It stays a normal optional field everywhere else: ignored on Slack/Discord/Telegram/KakaoTalk and any non-github session, on github replies outside a review thread, on attachments-only replies, and on mid-turn `more_work_this_turn:true` status updates — leave it unset there.) ' +
|
|
97
97
|
'Set `true` when your `text` acknowledges the concern is fixed/verified/addressed (e.g. "verified at <sha>", "thanks, that resolves it"): the runtime resolves the thread BEFORE posting, so the close-out actually happens in this same turn — a successful reply ends the turn, so a resolve deferred to "later" never runs. ' +
|
|
98
98
|
"Set `false` when the thread should stay open (partial fix, disagreement, mid-discussion). It is safe to set `true` by default: the runtime resolves ONLY if the thread's root comment is yours — it refuses (and blocks the reply) on a human reviewer's thread, so you never close someone else's open question. You need not pre-check authorship; let the runtime enforce ownership.",
|
|
99
99
|
}),
|
|
@@ -103,7 +103,7 @@ export function createChannelReplyTool({
|
|
|
103
103
|
async execute(_toolCallId, params) {
|
|
104
104
|
let text = params.text
|
|
105
105
|
const attachments = params.attachments
|
|
106
|
-
const keepTurnAlive = params.
|
|
106
|
+
const keepTurnAlive = params.more_work_this_turn === true
|
|
107
107
|
if ((text === undefined || text === '') && (attachments === undefined || attachments.length === 0)) {
|
|
108
108
|
logger.warn(formatChannelToolFailure('channel_reply', 'missing text and attachments'))
|
|
109
109
|
return {
|
|
@@ -164,7 +164,7 @@ export function createChannelReplyTool({
|
|
|
164
164
|
const missingResolveChoice = missingReviewThreadResolveChoiceError({
|
|
165
165
|
origin,
|
|
166
166
|
text,
|
|
167
|
-
|
|
167
|
+
moreWorkThisTurn: keepTurnAlive,
|
|
168
168
|
resolveReviewThread: params.resolve_review_thread,
|
|
169
169
|
})
|
|
170
170
|
if (missingResolveChoice) {
|
|
@@ -185,7 +185,7 @@ export function createChannelReplyTool({
|
|
|
185
185
|
chat: origin.chat,
|
|
186
186
|
thread: origin.thread,
|
|
187
187
|
text,
|
|
188
|
-
|
|
188
|
+
moreWorkThisTurn: keepTurnAlive,
|
|
189
189
|
resolveReviewThread: params.resolve_review_thread === true,
|
|
190
190
|
})
|
|
191
191
|
if (falseReceipt.kind === 'block') {
|
|
@@ -208,7 +208,7 @@ export function createChannelReplyTool({
|
|
|
208
208
|
thread: origin.thread,
|
|
209
209
|
text,
|
|
210
210
|
wantsResolve: params.resolve_review_thread === true,
|
|
211
|
-
|
|
211
|
+
moreWorkThisTurn: keepTurnAlive,
|
|
212
212
|
getReviewState: (req) => router.getReviewState(req),
|
|
213
213
|
})
|
|
214
214
|
if (rereview.block) {
|
|
@@ -259,19 +259,19 @@ export function createChannelReplyTool({
|
|
|
259
259
|
),
|
|
260
260
|
)
|
|
261
261
|
}
|
|
262
|
-
// `
|
|
262
|
+
// `more_work_this_turn` is read by the router's terminal hook (installChannelReplyTerminalHook),
|
|
263
263
|
// not by this tool — it suppresses the post-reply abort so a multi-step turn
|
|
264
264
|
// keeps going. Success-only: a denied reply never ran, so there is no turn to keep.
|
|
265
265
|
const details: {
|
|
266
266
|
ok: boolean
|
|
267
267
|
error?: string
|
|
268
|
-
|
|
268
|
+
more_work_this_turn?: boolean
|
|
269
269
|
messageId?: string
|
|
270
270
|
messageIds?: readonly string[]
|
|
271
271
|
} = result.ok
|
|
272
272
|
? {
|
|
273
273
|
ok: true,
|
|
274
|
-
...(keepTurnAlive ? {
|
|
274
|
+
...(keepTurnAlive ? { more_work_this_turn: true } : {}),
|
|
275
275
|
...(result.messageId !== undefined ? { messageId: result.messageId } : {}),
|
|
276
276
|
...(result.messageIds !== undefined ? { messageIds: result.messageIds } : {}),
|
|
277
277
|
}
|
|
@@ -329,13 +329,13 @@ export function createChannelReplyTool({
|
|
|
329
329
|
function missingReviewThreadResolveChoiceError(input: {
|
|
330
330
|
origin: ChannelReplyOrigin
|
|
331
331
|
text: string | undefined
|
|
332
|
-
|
|
332
|
+
moreWorkThisTurn: boolean
|
|
333
333
|
resolveReviewThread: boolean | undefined
|
|
334
334
|
}): string {
|
|
335
335
|
const isGithubPrReviewThread =
|
|
336
336
|
input.origin.adapter === 'github' && /^pr:\d+$/.test(input.origin.chat) && input.origin.thread !== null
|
|
337
337
|
const hasText = input.text !== undefined && input.text.trim() !== ''
|
|
338
|
-
if (!isGithubPrReviewThread || !hasText || input.
|
|
338
|
+
if (!isGithubPrReviewThread || !hasText || input.moreWorkThisTurn || input.resolveReviewThread !== undefined) {
|
|
339
339
|
return ''
|
|
340
340
|
}
|
|
341
341
|
return (
|
|
@@ -185,7 +185,7 @@ export function createChannelSendTool({
|
|
|
185
185
|
// via channel_send, and the model kept acknowledging "addressed" without
|
|
186
186
|
// the flag, stranding the thread — channel_reply forced the choice but
|
|
187
187
|
// channel_send did not, so the most-used resolve path was the least
|
|
188
|
-
// guarded. A send is always terminal, so there is no
|
|
188
|
+
// guarded. A send is always terminal, so there is no more-work exemption.
|
|
189
189
|
const missingResolveChoice = missingReviewThreadResolveChoiceError({
|
|
190
190
|
adapter,
|
|
191
191
|
chat: params.chat,
|
|
@@ -209,7 +209,7 @@ export function createChannelSendTool({
|
|
|
209
209
|
chat: params.chat,
|
|
210
210
|
thread: params.thread ?? null,
|
|
211
211
|
text: bodyText,
|
|
212
|
-
|
|
212
|
+
moreWorkThisTurn: false,
|
|
213
213
|
resolveReviewThread: wantsResolve,
|
|
214
214
|
})
|
|
215
215
|
if (falseReceipt.kind === 'block') {
|
|
@@ -231,7 +231,7 @@ export function createChannelSendTool({
|
|
|
231
231
|
thread: params.thread ?? null,
|
|
232
232
|
text: bodyText,
|
|
233
233
|
wantsResolve,
|
|
234
|
-
|
|
234
|
+
moreWorkThisTurn: false,
|
|
235
235
|
getReviewState: (req) => router.getReviewState(req),
|
|
236
236
|
})
|
|
237
237
|
if (rereview.block) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hooklessGitArgs } from '@/git/hookless'
|
|
2
1
|
import { resolveAgentGit } from '@/git/resolve-agent-git'
|
|
2
|
+
import { runGit } from '@/git/run'
|
|
3
3
|
import type { ContentPart, ToolResult } from '@/plugin'
|
|
4
4
|
|
|
5
5
|
export const GUARD_UNCOMMITTED_CHANGES = 'uncommittedChanges'
|
|
@@ -63,16 +63,9 @@ const defaultDeps: UncommittedChangesDeps = {
|
|
|
63
63
|
const bun = getBun()
|
|
64
64
|
if (!bun) return null
|
|
65
65
|
try {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
stdout: 'pipe',
|
|
70
|
-
stderr: 'pipe',
|
|
71
|
-
})
|
|
72
|
-
const exit = await proc.exited
|
|
73
|
-
if (exit !== 0) return null
|
|
74
|
-
const text = await new Response(proc.stdout).text()
|
|
75
|
-
return parsePorcelain(text)
|
|
66
|
+
const { exitCode, stdout } = await runGit(bun, agentDir, [...gitArgs, 'status', '--porcelain=v1'])
|
|
67
|
+
if (exitCode !== 0) return null
|
|
68
|
+
return parsePorcelain(stdout)
|
|
76
69
|
} catch {
|
|
77
70
|
return null
|
|
78
71
|
}
|
|
@@ -5,9 +5,9 @@ import { basename, join } from 'node:path'
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod'
|
|
7
7
|
|
|
8
|
-
import { hooklessGitArgs } from '@/git/hookless'
|
|
9
8
|
import { withGitLock } from '@/git/mutex'
|
|
10
9
|
import { type AgentGit, resolveAgentGit } from '@/git/resolve-agent-git'
|
|
10
|
+
import { runGit } from '@/git/run'
|
|
11
11
|
import { defineTool, lsTool, readTool, type Subagent, writeTool } from '@/plugin'
|
|
12
12
|
import { formatLocalDate, formatLocalDateTime } from '@/shared'
|
|
13
13
|
|
|
@@ -774,13 +774,8 @@ async function commitMemorySnapshotUnlocked(cwd: string): Promise<void> {
|
|
|
774
774
|
return
|
|
775
775
|
}
|
|
776
776
|
|
|
777
|
-
const add = bun.
|
|
778
|
-
|
|
779
|
-
cwd,
|
|
780
|
-
stdout: 'pipe',
|
|
781
|
-
stderr: 'pipe',
|
|
782
|
-
})
|
|
783
|
-
if ((await add.exited) !== 0) {
|
|
777
|
+
const add = await runGit(bun, cwd, [...repo.gitArgs, 'add', '-f', '--', ...presentPaths])
|
|
778
|
+
if (add.exitCode !== 0) {
|
|
784
779
|
await applySkipWorktree(bun, cwd, repo)
|
|
785
780
|
return
|
|
786
781
|
}
|
|
@@ -789,21 +784,20 @@ async function commitMemorySnapshotUnlocked(cwd: string): Promise<void> {
|
|
|
789
784
|
// pathspec only references files git knows about. `git commit -- foo bar/`
|
|
790
785
|
// fails outright when `bar/` matches no tracked file, even if `foo` is
|
|
791
786
|
// staged.
|
|
792
|
-
const stagedNames = bun
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if ((await stagedNames.exited) !== 0) {
|
|
787
|
+
const stagedNames = await runGit(bun, cwd, [
|
|
788
|
+
...repo.gitArgs,
|
|
789
|
+
'diff',
|
|
790
|
+
'--cached',
|
|
791
|
+
'--name-only',
|
|
792
|
+
'-z',
|
|
793
|
+
'--',
|
|
794
|
+
...SNAPSHOT_PATHS,
|
|
795
|
+
])
|
|
796
|
+
if (stagedNames.exitCode !== 0) {
|
|
803
797
|
await applySkipWorktree(bun, cwd, repo)
|
|
804
798
|
return
|
|
805
799
|
}
|
|
806
|
-
const staged =
|
|
800
|
+
const staged = stagedNames.stdout.split('\0').filter((p) => p.length > 0)
|
|
807
801
|
if (staged.length === 0) {
|
|
808
802
|
await applySkipWorktree(bun, cwd, repo)
|
|
809
803
|
return
|
|
@@ -811,13 +805,7 @@ async function commitMemorySnapshotUnlocked(cwd: string): Promise<void> {
|
|
|
811
805
|
|
|
812
806
|
const message = await buildCommitMessage(bun, cwd, staged, undefined, repo.gitArgs)
|
|
813
807
|
|
|
814
|
-
|
|
815
|
-
cmd: ['git', ...hooklessGitArgs([...repo.gitArgs, 'commit', '-m', message, '--only', '--', ...staged])],
|
|
816
|
-
cwd,
|
|
817
|
-
stdout: 'pipe',
|
|
818
|
-
stderr: 'pipe',
|
|
819
|
-
})
|
|
820
|
-
await commit.exited
|
|
808
|
+
await runGit(bun, cwd, [...repo.gitArgs, 'commit', '-m', message, '--only', '--', ...staged])
|
|
821
809
|
|
|
822
810
|
await applySkipWorktree(bun, cwd, repo)
|
|
823
811
|
}
|
|
@@ -868,14 +856,9 @@ async function buildDreamSummary(
|
|
|
868
856
|
): Promise<string> {
|
|
869
857
|
// numstat: `<added>\t<deleted>\t<path>` per line. Use NUL-terminated so paths
|
|
870
858
|
// with whitespace round-trip; -z switches the record separator to NUL.
|
|
871
|
-
const numstat = bun
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
stdout: 'pipe',
|
|
875
|
-
stderr: 'pipe',
|
|
876
|
-
})
|
|
877
|
-
const raw = await new Response(numstat.stdout).text()
|
|
878
|
-
if ((await numstat.exited) !== 0) return 'snapshot'
|
|
859
|
+
const numstat = await runGit(bun, cwd, [...gitArgs, 'diff', '--cached', '--numstat', '-z', '--', ...staged])
|
|
860
|
+
if (numstat.exitCode !== 0) return 'snapshot'
|
|
861
|
+
const raw = numstat.stdout
|
|
879
862
|
|
|
880
863
|
let fragmentLines = 0
|
|
881
864
|
const streamPaths = new Set<string>()
|
|
@@ -925,14 +908,9 @@ async function listNewlyAddedSkills(
|
|
|
925
908
|
staged: string[],
|
|
926
909
|
gitArgs: readonly string[] = [],
|
|
927
910
|
): Promise<string[]> {
|
|
928
|
-
const proc = bun
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
stdout: 'pipe',
|
|
932
|
-
stderr: 'pipe',
|
|
933
|
-
})
|
|
934
|
-
const raw = await new Response(proc.stdout).text()
|
|
935
|
-
if ((await proc.exited) !== 0) return []
|
|
911
|
+
const proc = await runGit(bun, cwd, [...gitArgs, 'diff', '--cached', '--name-status', '-z', '--', ...staged])
|
|
912
|
+
if (proc.exitCode !== 0) return []
|
|
913
|
+
const raw = proc.stdout
|
|
936
914
|
|
|
937
915
|
// `--name-status -z` interleaves status and path as separate NUL records:
|
|
938
916
|
// `A\0path\0M\0other\0...`. Pair them up.
|
|
@@ -953,39 +931,21 @@ async function listTrackedSnapshotFiles(
|
|
|
953
931
|
cwd: string,
|
|
954
932
|
repo: AgentGit,
|
|
955
933
|
): Promise<string[]> {
|
|
956
|
-
const ls = bun.
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
stdout: 'pipe',
|
|
960
|
-
stderr: 'pipe',
|
|
961
|
-
})
|
|
962
|
-
if ((await ls.exited) !== 0) return []
|
|
963
|
-
const raw = await new Response(ls.stdout).text()
|
|
964
|
-
return raw.split('\0').filter((p) => p.length > 0)
|
|
934
|
+
const ls = await runGit(bun, cwd, [...repo.gitArgs, 'ls-files', '-z', '--', ...SNAPSHOT_PATHS])
|
|
935
|
+
if (ls.exitCode !== 0) return []
|
|
936
|
+
return ls.stdout.split('\0').filter((p) => p.length > 0)
|
|
965
937
|
}
|
|
966
938
|
|
|
967
939
|
async function clearSkipWorktree(bun: { spawn: typeof Bun.spawn }, cwd: string, repo: AgentGit): Promise<void> {
|
|
968
940
|
const files = await listTrackedSnapshotFiles(bun, cwd, repo)
|
|
969
941
|
if (files.length === 0) return
|
|
970
|
-
|
|
971
|
-
cmd: ['git', ...hooklessGitArgs([...repo.gitArgs, 'update-index', '--no-skip-worktree', '--', ...files])],
|
|
972
|
-
cwd,
|
|
973
|
-
stdout: 'pipe',
|
|
974
|
-
stderr: 'pipe',
|
|
975
|
-
})
|
|
976
|
-
await proc.exited
|
|
942
|
+
await runGit(bun, cwd, [...repo.gitArgs, 'update-index', '--no-skip-worktree', '--', ...files])
|
|
977
943
|
}
|
|
978
944
|
|
|
979
945
|
async function applySkipWorktree(bun: { spawn: typeof Bun.spawn }, cwd: string, repo: AgentGit): Promise<void> {
|
|
980
946
|
const files = await listTrackedSnapshotFiles(bun, cwd, repo)
|
|
981
947
|
if (files.length === 0) return
|
|
982
|
-
|
|
983
|
-
cmd: ['git', ...hooklessGitArgs([...repo.gitArgs, 'update-index', '--skip-worktree', '--', ...files])],
|
|
984
|
-
cwd,
|
|
985
|
-
stdout: 'pipe',
|
|
986
|
-
stderr: 'pipe',
|
|
987
|
-
})
|
|
988
|
-
await proc.exited
|
|
948
|
+
await runGit(bun, cwd, [...repo.gitArgs, 'update-index', '--skip-worktree', '--', ...files])
|
|
989
949
|
}
|
|
990
950
|
|
|
991
951
|
export const DREAMING_SYSTEM_PROMPT = `You are typeclaw's dreaming subagent.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A channel turn ends after a successful `channel_reply` (the terminal-reply
|
|
2
2
|
// abort in router.ts). When the model's reply PROMISES to keep working this
|
|
3
3
|
// turn ("바로 확인해볼게요", "let me check", "I'll continue now") but it forgot
|
|
4
|
-
// to set `channel_reply({
|
|
4
|
+
// to set `channel_reply({ more_work_this_turn: true })`, the turn aborts and the promised
|
|
5
5
|
// follow-up never runs. The router uses this detector to inject ONE bounded
|
|
6
6
|
// reminder nudge so the model gets a second chance. See the empty-turn retry
|
|
7
7
|
// (router.ts) for the sibling mechanism this mirrors.
|
|
@@ -73,7 +73,7 @@ const EN_PHRASES: readonly string[] = [
|
|
|
73
73
|
// Action/config verb family. The retrieval verbs above ("check/look/look up")
|
|
74
74
|
// miss the much larger class of "I'll DO X" promises — update/configure/set up/
|
|
75
75
|
// schedule/fix/apply/create — which is exactly the class that silently truncates
|
|
76
|
-
// when the model forgets `
|
|
76
|
+
// when the model forgets `more_work_this_turn: true` (the cron-update production miss).
|
|
77
77
|
"i'll update",
|
|
78
78
|
"i'll set up",
|
|
79
79
|
"i'll set it up",
|
|
@@ -19,7 +19,7 @@ export type FalseReceiptInput = {
|
|
|
19
19
|
chat: string
|
|
20
20
|
thread: string | null
|
|
21
21
|
text: string | undefined
|
|
22
|
-
|
|
22
|
+
moreWorkThisTurn: boolean
|
|
23
23
|
resolveReviewThread: boolean
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -32,9 +32,9 @@ export function checkFalseReceipt(input: FalseReceiptInput): FalseReceiptDecisio
|
|
|
32
32
|
if (claim === 'ignore') return { kind: 'allow' }
|
|
33
33
|
if (claim === 'warn') return { kind: 'warn', notice: SOFT_NOTICE }
|
|
34
34
|
|
|
35
|
-
// A turn the agent explicitly keeps alive (
|
|
36
|
-
// — the real action may still be coming. Never block; nudge instead.
|
|
37
|
-
if (input.
|
|
35
|
+
// A turn the agent explicitly keeps alive (more_work_this_turn:true) is not yet
|
|
36
|
+
// a receipt — the real action may still be coming. Never block; nudge instead.
|
|
37
|
+
if (input.moreWorkThisTurn) return { kind: 'warn', notice: SOFT_NOTICE }
|
|
38
38
|
|
|
39
39
|
if (claim === 'block-resolve') {
|
|
40
40
|
if (input.thread === null) return { kind: 'allow' }
|
|
@@ -17,10 +17,10 @@ export type RereviewGuardInput = {
|
|
|
17
17
|
thread: string | null
|
|
18
18
|
text: string | undefined
|
|
19
19
|
wantsResolve: boolean
|
|
20
|
-
// A mid-turn status reply (
|
|
21
|
-
// suppresses the warn-tier escalation below — but never the explicit
|
|
22
|
-
// which is a real mutation. Mirrors the false-receipt guard's
|
|
23
|
-
|
|
20
|
+
// A mid-turn status reply (more_work_this_turn:true) is not the turn's receipt,
|
|
21
|
+
// so it suppresses the warn-tier escalation below — but never the explicit
|
|
22
|
+
// resolve, which is a real mutation. Mirrors the false-receipt guard's rule.
|
|
23
|
+
moreWorkThisTurn: boolean
|
|
24
24
|
getReviewState: (req: { adapter: 'github'; workspace: string; chat: string }) => Promise<ReviewStateResult>
|
|
25
25
|
workspace: string
|
|
26
26
|
}
|
|
@@ -62,14 +62,14 @@ export async function evaluateRereviewGuard(input: RereviewGuardInput): Promise<
|
|
|
62
62
|
// live CHANGES_REQUESTED, so casual approval-shaped chatter on an unblocked PR
|
|
63
63
|
// still posts. Only POSITIVE warn phrases escalate — negative ones ("needs
|
|
64
64
|
// changes", "still needs work") re-assert a block rather than strand it, so they
|
|
65
|
-
// stay non-firing. `
|
|
66
|
-
// planning, not the receipt), but never the explicit resolve action.
|
|
67
|
-
// `ignore` text never fires.
|
|
65
|
+
// stay non-firing. `more_work_this_turn:true` exempts the warn escalation
|
|
66
|
+
// (mid-turn planning, not the receipt), but never the explicit resolve action.
|
|
67
|
+
// Plain `ignore` text never fires.
|
|
68
68
|
function isCloseoutAttempt(input: RereviewGuardInput): boolean {
|
|
69
69
|
if (input.wantsResolve && input.thread !== null) return true
|
|
70
70
|
const claim = classifyReviewClaim(input.text ?? '')
|
|
71
71
|
if (claim === 'block-resolve' || claim === 'block-approve') return true
|
|
72
|
-
return !input.
|
|
72
|
+
return !input.moreWorkThisTurn && isPositiveWarnCloseout(input.text ?? '')
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function unverifiableReason(error: string): string {
|
package/src/channels/router.ts
CHANGED
|
@@ -371,7 +371,7 @@ export const EMPTY_TURN_RETRY_NUDGE = [
|
|
|
371
371
|
// Reminder-only nudge for the stranded-toolUse-after-send retry. Distinct from
|
|
372
372
|
// EMPTY_TURN_RETRY_NUDGE: that one diagnoses output-budget exhaustion and tells
|
|
373
373
|
// the model to "answer directly", which makes a stranded investigation RE-RUN
|
|
374
|
-
// its tools and strand again. Here the model already sent a `
|
|
374
|
+
// its tools and strand again. Here the model already sent a `more_work_this_turn: true`
|
|
375
375
|
// status ack and did real tool work; the turn just ended on an unanswered
|
|
376
376
|
// toolUse before final prose. The prior toolUse/toolResult entries are still in
|
|
377
377
|
// this session's branch on the re-prompt, so the recovery is to STOP, read what
|
|
@@ -424,8 +424,9 @@ export const COLD_START_REPLY_NUDGE = [
|
|
|
424
424
|
// Reminder-only nudge for the empty-stop-after-tool-work retry. Distinct from
|
|
425
425
|
// both EMPTY_TURN_RETRY_NUDGE (which misdiagnoses a clean `stop` as output-budget
|
|
426
426
|
// exhaustion and, per its own docstring, makes the model RE-RUN its tools and
|
|
427
|
-
// strand again) and STRANDED_TOOLUSE_CONTINUATION_NUDGE (which assumes a
|
|
428
|
-
// true` status reply already landed). Here NO send landed,
|
|
427
|
+
// strand again) and STRANDED_TOOLUSE_CONTINUATION_NUDGE (which assumes a
|
|
428
|
+
// `more_work_this_turn: true` status reply already landed). Here NO send landed,
|
|
429
|
+
// the model gathered real
|
|
429
430
|
// tool results, then the final completion came back as a bare empty `stop` — the
|
|
430
431
|
// Fireworks/gpt empty-completion degeneration. The recovery is to READ the results
|
|
431
432
|
// already in this branch, summarize, and reply — NOT to re-investigate. The
|
|
@@ -452,7 +453,7 @@ export const EMPTY_STOP_AFTER_TOOL_WORK_NUDGE = [
|
|
|
452
453
|
// is a one-shot correction offer, not recovery from no output.
|
|
453
454
|
export const MAX_WILLINGNESS_NUDGES = 1
|
|
454
455
|
// Injected when a reply that ended the turn (terminal-reply abort) promised to
|
|
455
|
-
// keep working but omitted `
|
|
456
|
+
// keep working but omitted `more_work_this_turn: true`. Reminder-only, SYSTEM MESSAGE
|
|
456
457
|
// framing so persona-rich models do not reply to the notice itself.
|
|
457
458
|
export const WILLINGNESS_NUDGE = [
|
|
458
459
|
'---',
|
|
@@ -460,14 +461,14 @@ export const WILLINGNESS_NUDGE = [
|
|
|
460
461
|
'',
|
|
461
462
|
'Your last reply said you would keep working this turn, but it ended right',
|
|
462
463
|
'after sending — a successful channel reply ends the turn unless you set',
|
|
463
|
-
'`
|
|
464
|
-
'not a message from anyone in the chat. **Do not acknowledge or reply to
|
|
465
|
-
'notice itself.**',
|
|
464
|
+
'`more_work_this_turn: true` on it. This is an automated signal from the channel',
|
|
465
|
+
'router, not a message from anyone in the chat. **Do not acknowledge or reply to',
|
|
466
|
+
'this notice itself.**',
|
|
466
467
|
'',
|
|
467
468
|
'If you still have work to do (fetch data, run a tool, spawn a subagent, then',
|
|
468
469
|
'reply with the result), do it now — and on the status reply that precedes more',
|
|
469
|
-
'work this turn, set `
|
|
470
|
-
'with `NO_REPLY`.',
|
|
470
|
+
'work this turn, set `more_work_this_turn: true`. If there is nothing left to do,',
|
|
471
|
+
'reply with `NO_REPLY`.',
|
|
471
472
|
'',
|
|
472
473
|
'---',
|
|
473
474
|
].join('\n')
|
|
@@ -475,7 +476,7 @@ export const WILLINGNESS_NUDGE = [
|
|
|
475
476
|
// did fresh work after it, then ended on an EMPTY `stop` leaf — the answer was
|
|
476
477
|
// computed but never sent (the Kimi/Fireworks empty-completion flake). Distinct
|
|
477
478
|
// from WILLINGNESS_NUDGE: that path is a `channel_reply` that ended the turn and
|
|
478
|
-
// needs `
|
|
479
|
+
// needs `more_work_this_turn: true`; this path is a `channel_send` (which never ends the
|
|
479
480
|
// turn) whose follow-up degenerated, so the model just needs to emit the reply it
|
|
480
481
|
// already worked out. Shares MAX_WILLINGNESS_NUDGES so a turn can't double-nudge.
|
|
481
482
|
export const SEND_WILLINGNESS_NUDGE = [
|
|
@@ -945,7 +946,7 @@ type LiveSession = {
|
|
|
945
946
|
// channel send landed this turn. `validateChannelTurn` compares it to the
|
|
946
947
|
// turn-end leaf: a DIFFERENT assistant `stop` leaf means the model replied,
|
|
947
948
|
// kept working, then ended with FRESH final prose it forgot to deliver
|
|
948
|
-
// (the `
|
|
949
|
+
// (the `more_work_this_turn: true` progress-reply bug) — recover it. A leaf that still
|
|
949
950
|
// matches is narration the model emitted BEFORE/with the reply that already
|
|
950
951
|
// landed, so it stays suppressed. Reset to null on every new prompt batch.
|
|
951
952
|
lastSendLeafId: string | null
|
|
@@ -1017,14 +1018,14 @@ type LiveSession = {
|
|
|
1017
1018
|
// nudge itself queues — same anti-reloop discipline as the empty-turn budget.
|
|
1018
1019
|
willingnessNudges: number
|
|
1019
1020
|
// Stashed by `installChannelReplyTerminalHook` just before it aborts the turn
|
|
1020
|
-
// after a successful `channel_reply` that omitted `
|
|
1021
|
+
// after a successful `channel_reply` that omitted `more_work_this_turn: true`. Read once
|
|
1021
1022
|
// by `validateChannelTurn` to decide the continuation nudge. `turnSeq`-stamped
|
|
1022
1023
|
// (like `skippedTurn`/`skipLockedSendTurn`) so a stale record from an earlier
|
|
1023
1024
|
// turn can never trigger a nudge on a later one. `null` when no such reply
|
|
1024
1025
|
// ended this turn.
|
|
1025
1026
|
lastTerminalReplyAbort: { turnSeq: number; text: string } | null
|
|
1026
1027
|
// Stamped by `installChannelReplyTerminalHook` when a successful `channel_reply`
|
|
1027
|
-
// set `
|
|
1028
|
+
// set `more_work_this_turn: true` — the machine-readable "I'll keep working this turn"
|
|
1028
1029
|
// promise. `validateChannelTurn` reads it to recover a turn that made that promise,
|
|
1029
1030
|
// did more work, then ended on a fresh empty `stop` (dropped its conclusion) —
|
|
1030
1031
|
// independent of what natural-language phrase the ack used, so a persona speaking
|
|
@@ -1085,6 +1086,26 @@ type LiveSession = {
|
|
|
1085
1086
|
// question escalation. Compared by `turnSeq` so a stale value can't leak across
|
|
1086
1087
|
// turns.
|
|
1087
1088
|
emptyTurnFallbackTurn: number | null
|
|
1089
|
+
// Set when a WILLINGNESS-ACK exhaustion path (empty_stop_after_continue_reply /
|
|
1090
|
+
// empty_stop_after_send_ack) would post EMPTY_TURN_FALLBACK_TEXT, but the model
|
|
1091
|
+
// just made a machine-readable promise to keep working (`more_work_this_turn: true` /
|
|
1092
|
+
// willingness phrase) and did post-ack tool work. Rather than posting the scary
|
|
1093
|
+
// "I got stuck" notice synchronously at validateChannelTurn — BEFORE the drain
|
|
1094
|
+
// loop runs maybeContinueTodosChannel, which can re-prompt the same logical turn
|
|
1095
|
+
// and land the real answer seconds later (the observed production false alarm) —
|
|
1096
|
+
// the cause is STAGED here and resolved after that continuation gets its chance:
|
|
1097
|
+
// discarded if a genuine reply lands or a continuation is queued, posted exactly
|
|
1098
|
+
// once if the turn genuinely stranded. Only the two willingness branches stage;
|
|
1099
|
+
// every other fallback path posts immediately as before (they carry no
|
|
1100
|
+
// continue-promise). Persists across reminder-only iterations (reset only on a
|
|
1101
|
+
// fresh user batch, beside the willingness/retry budgets) so a stage in one
|
|
1102
|
+
// iteration survives to the resolution after the next. `sendCountAtStage` is
|
|
1103
|
+
// `successfulChannelSends` at stage time — the resolver treats ONLY a send PAST
|
|
1104
|
+
// this baseline as a genuine recovery reply, because the willingness-ack that
|
|
1105
|
+
// triggered staging already bumped the turn-start count (the empty stop follows
|
|
1106
|
+
// a progress ack by definition), so a turn-start baseline would always read as
|
|
1107
|
+
// "already replied" and wrongly discard the fallback.
|
|
1108
|
+
stagedFallbackCause: { cause: string; sendCountAtStage: number } | null
|
|
1088
1109
|
// Stamped with `turnSeq` when a formal GitHub review (APPROVE / REQUEST_CHANGES /
|
|
1089
1110
|
// COMMENT) lands during this LOGICAL turn, via noteGithubReviewOutput off the
|
|
1090
1111
|
// review-output observer. On a github PR channel the agent's real deliverable is
|
|
@@ -1464,6 +1485,17 @@ export type ChannelRouter = {
|
|
|
1464
1485
|
lastTurnAuthorIds: readonly string[]
|
|
1465
1486
|
}
|
|
1466
1487
|
| undefined
|
|
1488
|
+
// Pushes a reminder onto the live session's `pendingSystemReminders`, the same
|
|
1489
|
+
// seam `runIdleContinuation`'s `deliver` callback uses when the todo/idle
|
|
1490
|
+
// continuation fires. Lets a test reproduce the production self-recovery race
|
|
1491
|
+
// (a continuation re-prompt queued after a willingness-ack strand) at the
|
|
1492
|
+
// channels layer, without coupling to todo-file persistence formats.
|
|
1493
|
+
injectContinuationReminder: (key: ChannelKey, text: string) => void
|
|
1494
|
+
// Enqueues a real user batch onto the live session's promptQueue via the same
|
|
1495
|
+
// `enqueue` path route() uses, letting a test reproduce a fresh inbound that
|
|
1496
|
+
// supersedes a still-pending staged fallback mid-drain (the A → staged B →
|
|
1497
|
+
// queued C question-signal supersession case) without the debounce timing dance.
|
|
1498
|
+
enqueueUserInbound: (key: ChannelKey, event: InboundMessage) => void
|
|
1467
1499
|
// Returns a shallow copy of `live.originRef.current` for the live
|
|
1468
1500
|
// session matching `key`, or undefined when no live session exists.
|
|
1469
1501
|
// Exists so tests can assert on the per-turn origin that tool.before
|
|
@@ -1505,6 +1537,14 @@ export type CreateChannelRouterOptions = {
|
|
|
1505
1537
|
// decision. Defaults to a stat()-based reader returning 0 for a missing or
|
|
1506
1538
|
// unreadable file (grace then fails closed to roll-over-at-soft-TTL).
|
|
1507
1539
|
measureTranscriptBytes?: (path: string) => number
|
|
1540
|
+
// Test seam: the idle/todo continuation driver, invoked from
|
|
1541
|
+
// maybeContinueTodosChannel AFTER validateChannelTurn. Defaults to the real
|
|
1542
|
+
// runIdleContinuation. Injecting it lets a test deliver the continuation at the
|
|
1543
|
+
// exact production phase (post-validation) so the drain-loop ordering —
|
|
1544
|
+
// resolveStagedFallback runs AFTER this delivery — is actually asserted, rather
|
|
1545
|
+
// than pre-seeding pendingSystemReminders from onPrompt (which would pass even if
|
|
1546
|
+
// the resolver moved ahead of the continuation).
|
|
1547
|
+
runIdleContinuation?: typeof runIdleContinuation
|
|
1508
1548
|
// Test seam: override the ensureLive watchdog ceiling so the timeout path
|
|
1509
1549
|
// is exercisable in <100ms instead of the 30s production default.
|
|
1510
1550
|
ensureLiveTimeoutMs?: number
|
|
@@ -2227,6 +2267,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2227
2267
|
skipLockedSendTurn: null,
|
|
2228
2268
|
disengagedTurn: null,
|
|
2229
2269
|
emptyTurnFallbackTurn: null,
|
|
2270
|
+
stagedFallbackCause: null,
|
|
2230
2271
|
githubReviewOutputTurn: null,
|
|
2231
2272
|
pendingQuoteCandidate: null,
|
|
2232
2273
|
recentEngagedPeerBotTurns: [],
|
|
@@ -2595,20 +2636,21 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2595
2636
|
// continue. A prior non-typeclaw `afterToolCall` (none today) would be
|
|
2596
2637
|
// composed, not clobbered.
|
|
2597
2638
|
//
|
|
2598
|
-
// `channel_reply({
|
|
2599
|
-
// status reply ("working on it…") that the model follows with more
|
|
2600
|
-
// turn. The tool surfaces that intent as
|
|
2601
|
-
// keep the follow-up so the turn
|
|
2602
|
-
//
|
|
2603
|
-
//
|
|
2639
|
+
// `channel_reply({ more_work_this_turn: true })` is the explicit opt-out: a
|
|
2640
|
+
// mid-turn status reply ("working on it…") that the model follows with more
|
|
2641
|
+
// work this turn. The tool surfaces that intent as
|
|
2642
|
+
// `details.more_work_this_turn === true`, and we keep the follow-up so the turn
|
|
2643
|
+
// proceeds. The kimi 32k loop only recurs when the model genuinely has nothing
|
|
2644
|
+
// left to say after a reply, which `more_work_this_turn` asserts is not the
|
|
2645
|
+
// case; Layer 2's maxTokens cap still bounds any misuse.
|
|
2604
2646
|
const installChannelReplyTerminalHook = (live: LiveSession): void => {
|
|
2605
2647
|
const { agent } = live.session
|
|
2606
2648
|
const prior = agent.afterToolCall
|
|
2607
2649
|
agent.afterToolCall = async (context, signal) => {
|
|
2608
2650
|
const result = prior ? await prior(context, signal) : undefined
|
|
2609
|
-
const details = context.result.details as { ok?: unknown;
|
|
2651
|
+
const details = context.result.details as { ok?: unknown; more_work_this_turn?: unknown } | undefined
|
|
2610
2652
|
const succeeded = context.toolCall.name === 'channel_reply' && !context.isError && details?.ok === true
|
|
2611
|
-
const keepTurnAlive = details?.
|
|
2653
|
+
const keepTurnAlive = details?.more_work_this_turn === true
|
|
2612
2654
|
if (succeeded && keepTurnAlive) {
|
|
2613
2655
|
live.continueReplyTurn = { turnSeq: live.turnSeq, sendCount: live.successfulChannelSends }
|
|
2614
2656
|
}
|
|
@@ -2733,7 +2775,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2733
2775
|
if (live.destroyed) return
|
|
2734
2776
|
if (live.promptQueue.length > 0 || live.pendingSystemReminders.length > 0) return
|
|
2735
2777
|
try {
|
|
2736
|
-
await runIdleContinuation({
|
|
2778
|
+
await (options.runIdleContinuation ?? runIdleContinuation)({
|
|
2737
2779
|
agentDir: options.agentDir,
|
|
2738
2780
|
origin: buildLiveOrigin(live),
|
|
2739
2781
|
deliver: (text) => {
|
|
@@ -2745,6 +2787,69 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2745
2787
|
}
|
|
2746
2788
|
}
|
|
2747
2789
|
|
|
2790
|
+
const postEmptyTurnFallback = async (live: LiveSession, cause: string): Promise<void> => {
|
|
2791
|
+
logger.warn(`[channels] ${live.keyId} empty_turn_fallback cause=${cause}`)
|
|
2792
|
+
live.emptyTurnFallbackTurn = live.turnSeq
|
|
2793
|
+
const result = await send(
|
|
2794
|
+
{
|
|
2795
|
+
adapter: live.key.adapter,
|
|
2796
|
+
workspace: live.key.workspace,
|
|
2797
|
+
chat: live.key.chat,
|
|
2798
|
+
thread: live.key.thread,
|
|
2799
|
+
text: EMPTY_TURN_FALLBACK_TEXT,
|
|
2800
|
+
},
|
|
2801
|
+
{ source: 'system' },
|
|
2802
|
+
)
|
|
2803
|
+
if (!result.ok) {
|
|
2804
|
+
logger.warn(`[channels] ${live.keyId}: empty-turn fallback send failed: ${result.error}`)
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
// Resolve a fallback STAGED by a willingness-ack exhaustion path, run AFTER
|
|
2809
|
+
// maybeContinueTodosChannel so the idle/todo continuation has already had its
|
|
2810
|
+
// chance to queue a re-prompt (the mechanism that self-recovers the promised
|
|
2811
|
+
// work). Three outcomes, in precedence order:
|
|
2812
|
+
// 1. A genuine reply landed this logical turn (successfulChannelSends moved
|
|
2813
|
+
// past the turn-start baseline; the staged path never posts, so any bump
|
|
2814
|
+
// is real prose) → the model self-recovered, discard the stage silently.
|
|
2815
|
+
// 2. A re-prompt is queued (pendingSystemReminders from the continuation, or a
|
|
2816
|
+
// fresh user inbound in promptQueue) → recovery is still in flight or a new
|
|
2817
|
+
// turn supersedes; carry the stage forward to the next resolution (or let
|
|
2818
|
+
// the fresh turn's reset clear it) — do NOT post yet.
|
|
2819
|
+
// 3. Neither → the turn genuinely stranded with nothing following it; post the
|
|
2820
|
+
// visible fallback exactly once. This preserves the never-strand-on-silence
|
|
2821
|
+
// invariant for the true-stuck case while killing the production false alarm
|
|
2822
|
+
// where the continuation landed the real answer seconds after the stage.
|
|
2823
|
+
const resolveStagedFallback = async (live: LiveSession): Promise<void> => {
|
|
2824
|
+
const staged = live.stagedFallbackCause
|
|
2825
|
+
if (staged === null) return
|
|
2826
|
+
if (live.successfulChannelSends > staged.sendCountAtStage) {
|
|
2827
|
+
logger.info(`[channels] ${live.keyId} empty_turn_fallback_discarded cause=${staged.cause} reason=reply_landed`)
|
|
2828
|
+
live.stagedFallbackCause = null
|
|
2829
|
+
// Recovery genuinely answered the user, so the logical turn ends as a usable
|
|
2830
|
+
// reply — commit the question signal the try-block deferred while staged.
|
|
2831
|
+
if (live.pendingUserTurnSignal !== null) {
|
|
2832
|
+
live.lastQuestionSignal = live.pendingUserTurnSignal.signal
|
|
2833
|
+
live.pendingUserTurnSignal = null
|
|
2834
|
+
}
|
|
2835
|
+
return
|
|
2836
|
+
}
|
|
2837
|
+
if (live.promptQueue.length > 0 || live.pendingSystemReminders.length > 0) {
|
|
2838
|
+
// A re-prompt is still queued: keep both the stage and the pending signal for
|
|
2839
|
+
// the next resolution — the turn hasn't finished.
|
|
2840
|
+
logger.info(
|
|
2841
|
+
`[channels] ${live.keyId} empty_turn_fallback_deferred cause=${staged.cause} reason=continuation_queued`,
|
|
2842
|
+
)
|
|
2843
|
+
return
|
|
2844
|
+
}
|
|
2845
|
+
live.stagedFallbackCause = null
|
|
2846
|
+
// The fallback IS the turn's terminal (non-usable) output — clear both signals
|
|
2847
|
+
// so an older question can't leak the xhigh escalation across this failed turn.
|
|
2848
|
+
live.pendingUserTurnSignal = null
|
|
2849
|
+
live.lastQuestionSignal = null
|
|
2850
|
+
await postEmptyTurnFallback(live, staged.cause)
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2748
2853
|
const fireSessionTurnStart = async (live: LiveSession, userPrompt: string): Promise<{ results: string }> => {
|
|
2749
2854
|
const retrievalContext = { results: '' }
|
|
2750
2855
|
if (!live.hooks) return retrievalContext
|
|
@@ -2965,6 +3070,16 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
2965
3070
|
live.toolLeakRetries = 0
|
|
2966
3071
|
live.emptyStopAfterToolWorkArmed = false
|
|
2967
3072
|
live.willingnessNudges = 0
|
|
3073
|
+
// A fresh batch supersedes a still-pending staged fallback. That staged
|
|
3074
|
+
// turn produced no usable reply, so it must not leave the PRIOR turn's
|
|
3075
|
+
// committed lastQuestionSignal behind — otherwise the new question would
|
|
3076
|
+
// inherit an xhigh escalation across the superseded (failed) turn. Clear
|
|
3077
|
+
// the stale signal only when a stage was actually pending; a normal prior
|
|
3078
|
+
// turn's legitimately-committed signal is left intact.
|
|
3079
|
+
if (live.stagedFallbackCause !== null) {
|
|
3080
|
+
live.lastQuestionSignal = null
|
|
3081
|
+
live.stagedFallbackCause = null
|
|
3082
|
+
}
|
|
2968
3083
|
live.abortReasonThisTurn = null
|
|
2969
3084
|
live.nextPromptMaxTokens = undefined
|
|
2970
3085
|
// Cleared with the retry budgets (NOT beside resetReviewTurn below) so a
|
|
@@ -3090,7 +3205,14 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3090
3205
|
const fallbackPostedThisTurn = live.emptyTurnFallbackTurn === live.turnSeq
|
|
3091
3206
|
const sentReplyThisTurn = live.successfulChannelSends > successfulSendsBeforePrompt
|
|
3092
3207
|
const usableReplyThisTurn = sentReplyThisTurn && !fallbackPostedThisTurn && !providerErrorThisTurn
|
|
3093
|
-
|
|
3208
|
+
// A staged (not-yet-posted) willingness fallback keeps the logical turn
|
|
3209
|
+
// OPEN, exactly like a queued retry: the progress ack that triggered
|
|
3210
|
+
// staging would otherwise read as `usableReplyThisTurn` and commit the
|
|
3211
|
+
// question signal, so a fallback turn would leak the `xhigh` escalation it
|
|
3212
|
+
// is meant to suppress. Leave the pending signal untouched here;
|
|
3213
|
+
// resolveStagedFallback finalizes it (commit on genuine recovery, clear on
|
|
3214
|
+
// fallback-post) once the continuation has run.
|
|
3215
|
+
if (live.pendingUserTurnSignal !== null && !retryQueuedThisTurn && live.stagedFallbackCause === null) {
|
|
3094
3216
|
live.lastQuestionSignal = usableReplyThisTurn ? live.pendingUserTurnSignal.signal : null
|
|
3095
3217
|
live.pendingUserTurnSignal = null
|
|
3096
3218
|
}
|
|
@@ -3165,6 +3287,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
3165
3287
|
await fireSessionIdle(live)
|
|
3166
3288
|
await recordTodoTurnStart(live, isRealUserTurn)
|
|
3167
3289
|
await maybeContinueTodosChannel(live)
|
|
3290
|
+
await resolveStagedFallback(live)
|
|
3168
3291
|
live.lastTurnAuthorIds = new Set(live.currentTurnAuthorIds)
|
|
3169
3292
|
if (live.currentTurnAuthorId !== null) {
|
|
3170
3293
|
live.lastTurnAuthorId = live.currentTurnAuthorId
|
|
@@ -4486,7 +4609,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4486
4609
|
}
|
|
4487
4610
|
|
|
4488
4611
|
// The turn ended via the terminal-reply abort. If that reply promised to keep
|
|
4489
|
-
// working but omitted `
|
|
4612
|
+
// working but omitted `more_work_this_turn: true`, queue ONE reminder-only re-prompt so
|
|
4490
4613
|
// the model gets a second chance to actually do it. The abort already fired
|
|
4491
4614
|
// (safe default preserved); this only adds an optional nudge. Bounded by
|
|
4492
4615
|
// MAX_WILLINGNESS_NUDGES and gated on `promptQueue` being empty so a real
|
|
@@ -4531,22 +4654,9 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4531
4654
|
live.skippedTurn = null
|
|
4532
4655
|
logger.info(`[channels] ${live.keyId} skip_contested_by_send recovering reply`)
|
|
4533
4656
|
}
|
|
4534
|
-
const
|
|
4535
|
-
logger.warn(`[channels] ${live.keyId}
|
|
4536
|
-
live.
|
|
4537
|
-
const result = await send(
|
|
4538
|
-
{
|
|
4539
|
-
adapter: live.key.adapter,
|
|
4540
|
-
workspace: live.key.workspace,
|
|
4541
|
-
chat: live.key.chat,
|
|
4542
|
-
thread: live.key.thread,
|
|
4543
|
-
text: EMPTY_TURN_FALLBACK_TEXT,
|
|
4544
|
-
},
|
|
4545
|
-
{ source: 'system' },
|
|
4546
|
-
)
|
|
4547
|
-
if (!result.ok) {
|
|
4548
|
-
logger.warn(`[channels] ${live.keyId}: empty-turn fallback send failed: ${result.error}`)
|
|
4549
|
-
}
|
|
4657
|
+
const stageEmptyTurnFallback = (cause: string): void => {
|
|
4658
|
+
logger.warn(`[channels] ${live.keyId} empty_turn_fallback_staged cause=${cause}`)
|
|
4659
|
+
live.stagedFallbackCause = { cause, sendCountAtStage: live.successfulChannelSends }
|
|
4550
4660
|
}
|
|
4551
4661
|
|
|
4552
4662
|
// A formal GitHub review already landed this logical turn (APPROVE /
|
|
@@ -4588,10 +4698,10 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4588
4698
|
)
|
|
4589
4699
|
}
|
|
4590
4700
|
|
|
4591
|
-
// A send landed this turn, but the model may have posted a `
|
|
4701
|
+
// A send landed this turn, but the model may have posted a `more_work_this_turn: true`
|
|
4592
4702
|
// progress reply, kept working, then ENDED with its final answer as plain
|
|
4593
4703
|
// prose — never calling a channel tool again. The terminal-reply abort fires
|
|
4594
|
-
// only for a `channel_reply` WITHOUT `
|
|
4704
|
+
// only for a `channel_reply` WITHOUT `more_work_this_turn: true`, so that `stopReason:
|
|
4595
4705
|
// 'stop'` text leaf is left undelivered and unguarded (the false-receipt
|
|
4596
4706
|
// guard is github-only). The discriminator is leaf IDENTITY: only when the
|
|
4597
4707
|
// turn-end `stop` leaf is a DIFFERENT entry than the one in place at the last
|
|
@@ -4601,17 +4711,17 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4601
4711
|
if (live.successfulChannelSends > successfulSendsBeforePrompt) {
|
|
4602
4712
|
maybeNudgeContinuationWillingness(live)
|
|
4603
4713
|
|
|
4604
|
-
// A `channel_reply({
|
|
4714
|
+
// A `channel_reply({ more_work_this_turn: true })` progress ack landed this turn (the
|
|
4605
4715
|
// machine-readable "I'll keep working" promise — `continueReplyTurn` is stamped
|
|
4606
4716
|
// by installChannelReplyTerminalHook), the model did more work, then ended on a
|
|
4607
4717
|
// FRESH empty `stop` — dropping its conclusion. This is the SAME degeneration as
|
|
4608
|
-
// the phrase-gated `channel_send` branch below, but keyed on the `
|
|
4718
|
+
// the phrase-gated `channel_send` branch below, but keyed on the `more_work_this_turn: true`
|
|
4609
4719
|
// FLAG instead of a natural-language willingness phrase. The flag is the robust
|
|
4610
4720
|
// signal: it fires regardless of the ack's language or register, closing the gap
|
|
4611
4721
|
// where a persona speaking a phrasing outside the willingness table (e.g. casual
|
|
4612
4722
|
// Korean "확인해볼게") stranded the user in silence. The `attemptMadeToolCall`
|
|
4613
4723
|
// half ties the first trigger to real post-ack work; `willingnessNudges > 0`
|
|
4614
|
-
// lets a retry that re-emitted `
|
|
4724
|
+
// lets a retry that re-emitted `more_work_this_turn: true` and re-stranded spend the shared
|
|
4615
4725
|
// budget toward the visible fallback instead of bailing silent. Same
|
|
4616
4726
|
// MAX_WILLINGNESS_NUDGES bound, same empty-`promptQueue` gate (a coalesced live
|
|
4617
4727
|
// inbound supersedes this turn's silence), and same nudge/fallback path as the
|
|
@@ -4637,7 +4747,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4637
4747
|
)
|
|
4638
4748
|
live.pendingSystemReminders.push(SEND_WILLINGNESS_NUDGE)
|
|
4639
4749
|
} else {
|
|
4640
|
-
|
|
4750
|
+
stageEmptyTurnFallback('empty_stop_after_continue_reply_nudges_exhausted')
|
|
4641
4751
|
}
|
|
4642
4752
|
return
|
|
4643
4753
|
}
|
|
@@ -4673,14 +4783,14 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4673
4783
|
)
|
|
4674
4784
|
live.pendingSystemReminders.push(SEND_WILLINGNESS_NUDGE)
|
|
4675
4785
|
} else {
|
|
4676
|
-
|
|
4786
|
+
stageEmptyTurnFallback('empty_stop_after_send_ack_nudges_exhausted')
|
|
4677
4787
|
}
|
|
4678
4788
|
return
|
|
4679
4789
|
}
|
|
4680
4790
|
|
|
4681
4791
|
const trailing = recoverableAssistantText(live.session)
|
|
4682
4792
|
if (trailing === null || trailing.source !== 'leaf') {
|
|
4683
|
-
// A `
|
|
4793
|
+
// A `more_work_this_turn: true` status reply landed, then the turn stranded on an
|
|
4684
4794
|
// unanswered `toolUse` (the post-tool follow-up never produced an
|
|
4685
4795
|
// assistant message — aborted loop / cancelled stream). The promised
|
|
4686
4796
|
// work never finished, so the user is left with a bare "checking now…"
|
|
@@ -4710,7 +4820,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4710
4820
|
)
|
|
4711
4821
|
live.pendingSystemReminders.push(STRANDED_TOOLUSE_CONTINUATION_NUDGE)
|
|
4712
4822
|
} else {
|
|
4713
|
-
await postEmptyTurnFallback('stranded_toolUse_retries_exhausted')
|
|
4823
|
+
await postEmptyTurnFallback(live, 'stranded_toolUse_retries_exhausted')
|
|
4714
4824
|
}
|
|
4715
4825
|
}
|
|
4716
4826
|
return
|
|
@@ -4826,7 +4936,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4826
4936
|
live.pendingSystemReminders.push(EMPTY_TURN_RETRY_NUDGE)
|
|
4827
4937
|
return
|
|
4828
4938
|
}
|
|
4829
|
-
await postEmptyTurnFallback(attemptedSendThisTurn ? 'send_thrash' : 'retries_exhausted')
|
|
4939
|
+
await postEmptyTurnFallback(live, attemptedSendThisTurn ? 'send_thrash' : 'retries_exhausted')
|
|
4830
4940
|
return
|
|
4831
4941
|
}
|
|
4832
4942
|
|
|
@@ -4861,7 +4971,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4861
4971
|
live.pendingSystemReminders.push(COLD_START_REPLY_NUDGE)
|
|
4862
4972
|
return
|
|
4863
4973
|
}
|
|
4864
|
-
await postEmptyTurnFallback('cold_start_solo_bare_empty_retries_exhausted')
|
|
4974
|
+
await postEmptyTurnFallback(live, 'cold_start_solo_bare_empty_retries_exhausted')
|
|
4865
4975
|
return
|
|
4866
4976
|
}
|
|
4867
4977
|
// Deliberately AFTER the cold-start guard (that path has its own nudge). A
|
|
@@ -4897,7 +5007,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
4897
5007
|
live.pendingSystemReminders.push(EMPTY_STOP_AFTER_TOOL_WORK_NUDGE)
|
|
4898
5008
|
return
|
|
4899
5009
|
}
|
|
4900
|
-
await postEmptyTurnFallback('empty_stop_after_tool_work_retries_exhausted')
|
|
5010
|
+
await postEmptyTurnFallback(live, 'empty_stop_after_tool_work_retries_exhausted')
|
|
4901
5011
|
return
|
|
4902
5012
|
}
|
|
4903
5013
|
const leakedReasoning = !isNoReplySignal(assistantText)
|
|
@@ -5061,7 +5171,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5061
5171
|
chat: live.key.chat,
|
|
5062
5172
|
thread: live.key.thread,
|
|
5063
5173
|
text,
|
|
5064
|
-
|
|
5174
|
+
moreWorkThisTurn: false,
|
|
5065
5175
|
resolveReviewThread: false,
|
|
5066
5176
|
})
|
|
5067
5177
|
if (falseReceipt.kind === 'block') return falseReceipt.reason
|
|
@@ -5073,7 +5183,7 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5073
5183
|
thread: live.key.thread,
|
|
5074
5184
|
text,
|
|
5075
5185
|
wantsResolve: false,
|
|
5076
|
-
|
|
5186
|
+
moreWorkThisTurn: false,
|
|
5077
5187
|
getReviewState: (req) => getReviewState(req),
|
|
5078
5188
|
})
|
|
5079
5189
|
if (rereview.block) return rereview.reason
|
|
@@ -5954,6 +6064,16 @@ export function createChannelRouter(options: CreateChannelRouterOptions): Channe
|
|
|
5954
6064
|
lastTurnAuthorIds: Array.from(live.lastTurnAuthorIds),
|
|
5955
6065
|
}
|
|
5956
6066
|
},
|
|
6067
|
+
injectContinuationReminder: (key: ChannelKey, text: string): void => {
|
|
6068
|
+
const live = liveSessions.get(channelKeyId(key))
|
|
6069
|
+
if (!live) return
|
|
6070
|
+
live.pendingSystemReminders.push(text)
|
|
6071
|
+
},
|
|
6072
|
+
enqueueUserInbound: (key: ChannelKey, event: InboundMessage): void => {
|
|
6073
|
+
const live = liveSessions.get(channelKeyId(key))
|
|
6074
|
+
if (!live) return
|
|
6075
|
+
enqueue(live, event, null)
|
|
6076
|
+
},
|
|
5957
6077
|
},
|
|
5958
6078
|
}
|
|
5959
6079
|
}
|
|
@@ -6858,7 +6978,7 @@ function assistantLeafStopReason(session: AgentSession): 'length' | 'error' | 'a
|
|
|
6858
6978
|
// alongside its tool call and DID land a real send this turn (that trailing
|
|
6859
6979
|
// `toolUse` is delivered narration, not a stranded promise — leave it alone).
|
|
6860
6980
|
// Keys on the model having INTENDED to keep working with nothing yet said; used
|
|
6861
|
-
// to re-prompt a turn that strands mid-work after a `
|
|
6981
|
+
// to re-prompt a turn that strands mid-work after a `more_work_this_turn: true` status
|
|
6862
6982
|
// reply instead of ending in silence.
|
|
6863
6983
|
function leafIsStrandedToolUse(session: AgentSession): boolean {
|
|
6864
6984
|
const leaf = session.sessionManager.getLeafEntry()
|
|
@@ -6888,7 +7008,7 @@ function leafIsStrandedToolUse(session: AgentSession): boolean {
|
|
|
6888
7008
|
// (the model did more work, then dropped its conclusion) from a legitimate
|
|
6889
7009
|
// ack-then-stop where the model meant to wait for the user (leaf unchanged since
|
|
6890
7010
|
// the send). The two willingness paths below layer their own promise-signal on top
|
|
6891
|
-
// of this shape: `channel_reply({
|
|
7011
|
+
// of this shape: `channel_reply({ more_work_this_turn: true })` via `continueReplyTurn`, and
|
|
6892
7012
|
// `channel_send` acks via the willingness phrase table.
|
|
6893
7013
|
function isFreshEmptyStopAfterSend(live: LiveSession): boolean {
|
|
6894
7014
|
const leaf = live.session.sessionManager.getLeafEntry()
|
|
@@ -6898,10 +7018,10 @@ function isFreshEmptyStopAfterSend(live: LiveSession): boolean {
|
|
|
6898
7018
|
return leaf.id !== live.lastSendLeafId
|
|
6899
7019
|
}
|
|
6900
7020
|
|
|
6901
|
-
// The `channel_send` analogue of the `
|
|
7021
|
+
// The `channel_send` analogue of the `more_work_this_turn: true` recovery: the most recent
|
|
6902
7022
|
// send to this target was a continuation-willingness ack (by phrase), then the
|
|
6903
7023
|
// model produced a fresh empty stop. `channel_send` keeps the turn alive without a
|
|
6904
|
-
// `
|
|
7024
|
+
// `more_work_this_turn: true` flag and stamps no semantic marker, so the phrase table is the
|
|
6905
7025
|
// only "I promised to keep working" signal available for that shape.
|
|
6906
7026
|
function isEmptyStopAfterWillingnessAck(live: LiveSession): boolean {
|
|
6907
7027
|
if (!isFreshEmptyStopAfterSend(live)) return false
|
package/src/git/run.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { hooklessGitArgs } from './hookless'
|
|
2
|
+
|
|
3
|
+
export type RunGitResult = {
|
|
4
|
+
exitCode: number
|
|
5
|
+
stdout: string
|
|
6
|
+
stderr: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type DrainableProcess = {
|
|
10
|
+
stdout: { text: () => Promise<string> }
|
|
11
|
+
stderr: { text: () => Promise<string> }
|
|
12
|
+
exited: Promise<number>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// `proc.exited` only signals child termination; it does not consume or close
|
|
16
|
+
// the piped stdout/stderr streams. A stream left undrained holds its parent
|
|
17
|
+
// read-end fd until GC finalizes it, so awaiting exit alone lets fds accumulate
|
|
18
|
+
// under memory pressure (delayed GC) — the leak this helper exists to stop.
|
|
19
|
+
// Draining both streams to EOF makes `runGit` own the full resource lifecycle:
|
|
20
|
+
// it does not resolve until the process has exited AND both pipes are closed.
|
|
21
|
+
// Both reads are STARTED before we await, so neither can be starved by the
|
|
22
|
+
// other (Bun v1.3.14 buffers subprocess output internally, so this is about
|
|
23
|
+
// deterministic fd release, not an OS pipe-capacity deadlock).
|
|
24
|
+
async function collectProcessOutput(proc: DrainableProcess): Promise<RunGitResult> {
|
|
25
|
+
const stdoutDrain = proc.stdout.text()
|
|
26
|
+
const stderrDrain = proc.stderr.text()
|
|
27
|
+
const exited = proc.exited
|
|
28
|
+
const [exitCode, stdout, stderr] = await Promise.all([exited, stdoutDrain, stderrDrain])
|
|
29
|
+
return { exitCode, stdout, stderr }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function runGit(
|
|
33
|
+
bun: { spawn: typeof Bun.spawn },
|
|
34
|
+
cwd: string,
|
|
35
|
+
args: readonly string[],
|
|
36
|
+
): Promise<RunGitResult> {
|
|
37
|
+
const proc = bun.spawn({
|
|
38
|
+
cmd: ['git', ...hooklessGitArgs(args)],
|
|
39
|
+
cwd,
|
|
40
|
+
stdout: 'pipe',
|
|
41
|
+
stderr: 'pipe',
|
|
42
|
+
})
|
|
43
|
+
const drainable: DrainableProcess = {
|
|
44
|
+
stdout: { text: () => Bun.readableStreamToText(proc.stdout) },
|
|
45
|
+
stderr: { text: () => Bun.readableStreamToText(proc.stderr) },
|
|
46
|
+
exited: proc.exited,
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return await collectProcessOutput(drainable)
|
|
50
|
+
} catch (drainErr) {
|
|
51
|
+
// A pipe-read rejection must not escape while the child may still be
|
|
52
|
+
// running: kill it, then let exit and both drains settle so no fd is left
|
|
53
|
+
// dangling behind the error.
|
|
54
|
+
proc.kill()
|
|
55
|
+
await Promise.allSettled([drainable.exited, drainable.stdout.text(), drainable.stderr.text()])
|
|
56
|
+
throw drainErr
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const _internal = { collectProcessOutput }
|
|
@@ -10,9 +10,9 @@ GitHub renders normal Markdown in issues, PRs, discussions, and review comments.
|
|
|
10
10
|
- For PR review threads, keep `thread` set to reply in-place. Omit `thread` for a top-level PR/issue comment.
|
|
11
11
|
- When a review comment **you authored** has been addressed, resolve its thread by replying with `channel_reply({ …, resolve_review_thread: true })` — see "Resolving review threads you authored" below. The base principle is **whoever opened the thread closes it**: you resolve only the threads you started, never a human's (the runtime enforces this).
|
|
12
12
|
|
|
13
|
-
## Mid-turn status replies need `
|
|
13
|
+
## Mid-turn status replies need `more_work_this_turn: true`
|
|
14
14
|
|
|
15
|
-
A successful `channel_reply` ends your turn by default — the runtime stops the model right after the reply lands. That is correct for a final answer, but it will **silently truncate** a turn that still has work to do. If you post a status line like "Reviewing now, I'll be back with findings" and then expect to keep working (fetch the diff, spawn the reviewer, post the review) in the **same** turn, you must call `channel_reply({ text: "…",
|
|
15
|
+
A successful `channel_reply` ends your turn by default — the runtime stops the model right after the reply lands. That is correct for a final answer, but it will **silently truncate** a turn that still has work to do. If you post a status line like "Reviewing now, I'll be back with findings" and then expect to keep working (fetch the diff, spawn the reviewer, post the review) in the **same** turn, you must call `channel_reply({ text: "…", more_work_this_turn: true })`. Without `more_work_this_turn: true`, the turn ends at that status reply and the review never runs. Reserve `more_work_this_turn: true` for genuine multi-step turns; the final reply that wraps up the turn sets `more_work_this_turn: false`. The field is required — every `channel_reply` must set it explicitly, so never omit it.
|
|
16
16
|
|
|
17
17
|
## Inbound triage — do this first, every time
|
|
18
18
|
|
|
@@ -259,10 +259,10 @@ If the author merely **replied** without pushing (e.g. "this is intentional beca
|
|
|
259
259
|
Once you have verified the fix, **acknowledge and resolve in one call**: pass `resolve_review_thread: true` to your `channel_reply`. The runtime resolves the thread you're replying in **before** it posts your acknowledgement, then posts the reply:
|
|
260
260
|
|
|
261
261
|
```
|
|
262
|
-
channel_reply({ text: "Verified — the fix addresses the concern. Thanks!", resolve_review_thread: true })
|
|
262
|
+
channel_reply({ text: "Verified — the fix addresses the concern. Thanks!", more_work_this_turn: false, resolve_review_thread: true })
|
|
263
263
|
```
|
|
264
264
|
|
|
265
|
-
This is the correct path and it removes a footgun. A bare `channel_reply` ends your turn the moment it lands, so a resolve attempted _after_ the acknowledgement would never run — the thread would stay open even though you "handled" it. The flag resolves first, so a normal final reply still closes the thread. You do **not** need `
|
|
265
|
+
This is the correct path and it removes a footgun. A bare `channel_reply` ends your turn the moment it lands, so a resolve attempted _after_ the acknowledgement would never run — the thread would stay open even though you "handled" it. The flag resolves first, so a normal final reply still closes the thread. You do **not** need `more_work_this_turn: true` for this: resolution happens inside the same call, before the turn ends.
|
|
266
266
|
|
|
267
267
|
Two guarantees make the flag safe to use as your default:
|
|
268
268
|
|