@openclaw-cloud/agent-controller 3.0.0-beta.21 → 3.0.0-beta.22
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.
|
@@ -18,14 +18,18 @@ export interface MockBoardWorkerHandle {
|
|
|
18
18
|
* create the CardProcessing, dispatch the prompt and block the CP in
|
|
19
19
|
* `waiting_for_mcp_response`; the mock never receives that prompt, it
|
|
20
20
|
* just has to submit after the CP exists.
|
|
21
|
-
* 3. `POST /api/agent/board/cards/{cardId}/submit` — retried
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* 3. `POST /api/agent/board/cards/{cardId}/submit` — retried, because a
|
|
22
|
+
* submit landing before the CP is blocked gets a 404 (`no active
|
|
23
|
+
* card_processing`) or 400 (`not waiting for a response`). How long we
|
|
24
|
+
* retry depends on which: see the budget constants above.
|
|
25
25
|
* 4. Straight back to take-task, so a burst of waiting cards drains
|
|
26
26
|
* back-to-back instead of one per poll interval.
|
|
27
27
|
*
|
|
28
28
|
* Nothing in here may throw out of the loop: a mock agent that dies on a
|
|
29
|
-
* transient backend blip is worse than one that logs and polls again.
|
|
29
|
+
* transient backend blip is worse than one that logs and polls again. Every
|
|
30
|
+
* exit from `submit()` falls back into the polling loop — only `stop()` ends
|
|
31
|
+
* it. A card we could not submit is left claimed, which blocks further work
|
|
32
|
+
* until the orchestrator releases it, so `submit()` returning is always
|
|
33
|
+
* logged.
|
|
30
34
|
*/
|
|
31
35
|
export declare function startMockBoardWorker(opts: MockBoardWorkerOptions): MockBoardWorkerHandle;
|
|
@@ -2,8 +2,30 @@ import { config } from './config.js';
|
|
|
2
2
|
import { toErrorMessage } from './utils/response.js';
|
|
3
3
|
/** Backoff between submit retries while the orchestrator blocks the CardProcessing. */
|
|
4
4
|
const SUBMIT_RETRY_DELAY_MS = 2_000;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Budget for HTTP 400 `Card processing is not waiting for a response` — the CP
|
|
7
|
+
* exists and is ours, it just has not reached the `agent_mcp_task` step yet.
|
|
8
|
+
*
|
|
9
|
+
* Long on purpose. Abandoning the card does NOT release it: `claimCard` has a
|
|
10
|
+
* universal one-card-per-agent guard, so while this card is still assigned to
|
|
11
|
+
* us every later take-task is refused and answered 204. The only thing that
|
|
12
|
+
* frees us is the orchestrator reconciler reaping the stalled CP at
|
|
13
|
+
* `cp.stallTimeoutMs` (default 30 min), which fails the CP and unassigns the
|
|
14
|
+
* card. Giving up before that bought nothing and made the agent look idle for
|
|
15
|
+
* up to half an hour — that is the 2026-08-30 local-stack wedge.
|
|
16
|
+
*/
|
|
17
|
+
const SUBMIT_NOT_READY_BUDGET_MS = 31 * 60_000;
|
|
18
|
+
/**
|
|
19
|
+
* Budget for HTTP 404 `no active card_processing` — no CP is active on the
|
|
20
|
+
* card. Short, because this reads two ways and both want a quick exit:
|
|
21
|
+
* either the orchestrator has not created the CP yet (a seconds-wide window
|
|
22
|
+
* right after the claim), or it has already been reaped — and a reap also
|
|
23
|
+
* unassigns the card, so we are free to claim again and should be polling,
|
|
24
|
+
* not retrying.
|
|
25
|
+
*/
|
|
26
|
+
const SUBMIT_NO_CP_BUDGET_MS = 60_000;
|
|
27
|
+
/** Log attempt 1, then every Nth — a half-hour wait is not 900 log lines. */
|
|
28
|
+
const SUBMIT_LOG_EVERY = 15;
|
|
7
29
|
/**
|
|
8
30
|
* Board worker for the `mock` provider — the piece that makes a mock agent
|
|
9
31
|
* process board cards end to end so the platform can be developed locally
|
|
@@ -17,15 +39,19 @@ const SUBMIT_RETRY_BUDGET_MS = 60_000;
|
|
|
17
39
|
* create the CardProcessing, dispatch the prompt and block the CP in
|
|
18
40
|
* `waiting_for_mcp_response`; the mock never receives that prompt, it
|
|
19
41
|
* just has to submit after the CP exists.
|
|
20
|
-
* 3. `POST /api/agent/board/cards/{cardId}/submit` — retried
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
42
|
+
* 3. `POST /api/agent/board/cards/{cardId}/submit` — retried, because a
|
|
43
|
+
* submit landing before the CP is blocked gets a 404 (`no active
|
|
44
|
+
* card_processing`) or 400 (`not waiting for a response`). How long we
|
|
45
|
+
* retry depends on which: see the budget constants above.
|
|
24
46
|
* 4. Straight back to take-task, so a burst of waiting cards drains
|
|
25
47
|
* back-to-back instead of one per poll interval.
|
|
26
48
|
*
|
|
27
49
|
* Nothing in here may throw out of the loop: a mock agent that dies on a
|
|
28
|
-
* transient backend blip is worse than one that logs and polls again.
|
|
50
|
+
* transient backend blip is worse than one that logs and polls again. Every
|
|
51
|
+
* exit from `submit()` falls back into the polling loop — only `stop()` ends
|
|
52
|
+
* it. A card we could not submit is left claimed, which blocks further work
|
|
53
|
+
* until the orchestrator releases it, so `submit()` returning is always
|
|
54
|
+
* logged.
|
|
29
55
|
*/
|
|
30
56
|
export function startMockBoardWorker(opts) {
|
|
31
57
|
const { api } = opts;
|
|
@@ -71,8 +97,14 @@ export function startMockBoardWorker(opts) {
|
|
|
71
97
|
}
|
|
72
98
|
}
|
|
73
99
|
async function submit(cardId) {
|
|
74
|
-
const
|
|
75
|
-
|
|
100
|
+
const start = Date.now();
|
|
101
|
+
// Which budget applies depends on the LAST failure: 404 means no CP is
|
|
102
|
+
// active on the card, so the short budget takes over immediately — that is
|
|
103
|
+
// what turns a reap into a prompt return to polling even after we have
|
|
104
|
+
// already waited many minutes on 400s.
|
|
105
|
+
let budgetMs = SUBMIT_NOT_READY_BUDGET_MS;
|
|
106
|
+
for (let attempt = 1; !stopped; attempt++) {
|
|
107
|
+
const loud = attempt === 1 || attempt % SUBMIT_LOG_EVERY === 0;
|
|
76
108
|
try {
|
|
77
109
|
const res = await api.post(`/api/agent/board/cards/${cardId}/submit`, {
|
|
78
110
|
text: config.mockTaskText,
|
|
@@ -83,13 +115,27 @@ export function startMockBoardWorker(opts) {
|
|
|
83
115
|
return;
|
|
84
116
|
}
|
|
85
117
|
const body = await res.text().catch(() => '');
|
|
86
|
-
|
|
118
|
+
// 403 `Card is not claimed by this agent` is terminal: the card was
|
|
119
|
+
// reaped and re-paired, so it is no longer ours to submit and no
|
|
120
|
+
// amount of retrying changes that. Go back to polling at once.
|
|
121
|
+
if (res.status === 403) {
|
|
122
|
+
console.warn(`[mock-board] card ${cardId} no longer ours (HTTP 403) — resuming polling`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
budgetMs = res.status === 404 ? SUBMIT_NO_CP_BUDGET_MS : SUBMIT_NOT_READY_BUDGET_MS;
|
|
126
|
+
if (loud) {
|
|
127
|
+
console.warn(`[mock-board] submit ${cardId} not ready (attempt ${attempt}, HTTP ${res.status}) ${body.slice(0, 200)}`);
|
|
128
|
+
}
|
|
87
129
|
}
|
|
88
130
|
catch (err) {
|
|
89
|
-
|
|
131
|
+
if (loud) {
|
|
132
|
+
console.warn(`[mock-board] submit ${cardId} error (attempt ${attempt}): ${toErrorMessage(err)}`);
|
|
133
|
+
}
|
|
90
134
|
}
|
|
91
|
-
if (Date.now() >=
|
|
92
|
-
console.warn(`[mock-board] giving up on card ${cardId} after ${
|
|
135
|
+
if (Date.now() - start >= budgetMs) {
|
|
136
|
+
console.warn(`[mock-board] giving up on card ${cardId} after ${Math.round((Date.now() - start) / 1000)}s; ` +
|
|
137
|
+
'it stays claimed by this agent until the orchestrator reconciler reaps the ' +
|
|
138
|
+
'stalled card_processing, so take-task keeps answering 204 until then. Resuming polling.');
|
|
93
139
|
return;
|
|
94
140
|
}
|
|
95
141
|
await sleep(SUBMIT_RETRY_DELAY_MS);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-board-worker.js","sourceRoot":"","sources":["../src/mock-board-worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,uFAAuF;AACvF,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,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