@tea-agent/loop-agent 0.44.0-next.10 → 0.44.0-next.11

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.
@@ -0,0 +1,60 @@
1
+ export const WRITER_THINKING_EXHAUSTED_CATEGORY = "writer-thinking-exhausted";
2
+ export const PLANNER_THINKING_EXHAUSTED_CATEGORY = "planner-thinking-exhausted";
3
+ export function isPlannerThinkingExhausted(result, committedAnyFacts) {
4
+ if (result.ok)
5
+ return false;
6
+ const evidence = readWriterThinkingExhaustionEvidence(result);
7
+ if (evidence.stopReason !== "length")
8
+ return false;
9
+ if (evidence.thinkingObserved !== true)
10
+ return false;
11
+ if (committedAnyFacts)
12
+ return false;
13
+ if ((result.assistantText ?? "").trim())
14
+ return false;
15
+ // Gateways sometimes relabel a length-stopped stream as `network` or
16
+ // `nonzero-exit`; provider evidence outweighs the transport label.
17
+ if (result.failureCategory &&
18
+ !["empty-output", "network", "nonzero-exit", "unknown"].includes(result.failureCategory))
19
+ return false;
20
+ return true;
21
+ }
22
+ export const WRITER_BUDGET_EXHAUSTED_CATEGORY = "writer-budget-exhausted";
23
+ export const WRITER_TOKEN_BUDGET = 2_000_000;
24
+ export function readWriterThinkingExhaustionEvidence(result) {
25
+ const wider = result;
26
+ return {
27
+ ...(typeof wider.stopReason === "string"
28
+ ? { stopReason: wider.stopReason }
29
+ : {}),
30
+ ...(typeof wider.thinkingObserved === "boolean"
31
+ ? { thinkingObserved: wider.thinkingObserved }
32
+ : {}),
33
+ ...(typeof wider.writeToolCallCount === "number"
34
+ ? { writeToolCallCount: wider.writeToolCallCount }
35
+ : {}),
36
+ };
37
+ }
38
+ export function isWriterThinkingExhausted(result, mapped, changeManifestChangedFiles) {
39
+ if (mapped.ok)
40
+ return false;
41
+ const evidence = readWriterThinkingExhaustionEvidence(result);
42
+ if (evidence.stopReason !== "length")
43
+ return false;
44
+ if (evidence.thinkingObserved !== true)
45
+ return false;
46
+ if ((evidence.writeToolCallCount ?? 0) !== 0)
47
+ return false;
48
+ // Gateways sometimes classify a length-stopped stream as `network` or
49
+ // `nonzero-exit` because the terminal event is carried in stderr. The
50
+ // provider evidence is stronger than that transport label when no write
51
+ // tool was called and the run produced no diff.
52
+ if (mapped.failureCategory &&
53
+ !["empty-output", "network", "nonzero-exit", "unknown"].includes(mapped.failureCategory))
54
+ return false;
55
+ if (changeManifestChangedFiles === undefined)
56
+ return false;
57
+ if (changeManifestChangedFiles.length !== 0)
58
+ return false;
59
+ return true;
60
+ }