Fix code mode yield startup race (#14959)
This commit is contained in:
parent
d484bb57d9
commit
0d531c05f2
1 changed files with 10 additions and 5 deletions
|
|
@ -465,6 +465,7 @@ function codeModeWorkerMain() {
|
|||
writable: false,
|
||||
});
|
||||
|
||||
parentPort.postMessage({ type: 'started' });
|
||||
try {
|
||||
await runModule(context, start, callTool, helpers);
|
||||
parentPort.postMessage({
|
||||
|
|
@ -639,6 +640,10 @@ function startSession(protocol, sessions, start) {
|
|||
content_items: [],
|
||||
default_yield_time_ms: normalizeYieldTime(start.default_yield_time_ms),
|
||||
id: start.cell_id,
|
||||
initial_yield_time_ms:
|
||||
start.yield_time_ms == null
|
||||
? normalizeYieldTime(start.default_yield_time_ms)
|
||||
: normalizeYieldTime(start.yield_time_ms),
|
||||
initial_yield_timer: null,
|
||||
initial_yield_triggered: false,
|
||||
max_output_tokens_per_exec_call: maxOutputTokensPerExecCall,
|
||||
|
|
@ -651,11 +656,6 @@ function startSession(protocol, sessions, start) {
|
|||
}),
|
||||
};
|
||||
sessions.set(session.id, session);
|
||||
const initialYieldTime =
|
||||
start.yield_time_ms == null
|
||||
? session.default_yield_time_ms
|
||||
: normalizeYieldTime(start.yield_time_ms);
|
||||
scheduleInitialYield(protocol, session, initialYieldTime);
|
||||
|
||||
session.worker.on('message', (message) => {
|
||||
void handleWorkerMessage(protocol, sessions, session, message).catch((error) => {
|
||||
|
|
@ -694,6 +694,11 @@ async function handleWorkerMessage(protocol, sessions, session, message) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'started') {
|
||||
scheduleInitialYield(protocol, session, session.initial_yield_time_ms);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'yield') {
|
||||
void sendYielded(protocol, session);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue