fix worker forreal
Build and Push Spoon Images / quality (push) Successful in 1m45s
Build and Push Spoon Images / build-images (push) Successful in 7m35s

This commit is contained in:
Gabriel Brown
2026-06-23 21:38:41 -04:00
parent c3d265d428
commit 30a17196f5
5 changed files with 169 additions and 39 deletions
+49 -26
View File
@@ -110,6 +110,7 @@ type ActiveWorkspace = {
codexSessionId?: string;
agentTurnActive?: boolean;
resolveTurn?: () => void;
lastRecordedDiffSignature?: string;
};
type FileTreeNode = {
@@ -430,8 +431,8 @@ const codexModel = (claim: Claim) => {
return model.includes('/') ? model.split('/').at(-1) ?? model : model;
};
const codexModelFlag = (claim: Claim) =>
isCodexLoginProfile(claim) ? '' : ` --model ${quoteShell(codexModel(claim))}`;
const codexModelArgs = (claim: Claim) =>
isCodexLoginProfile(claim) ? [] : ['--model', codexModel(claim)];
const writeJsonFile = async (filePath: string, content: string) => {
let normalized = content.trim();
@@ -696,20 +697,26 @@ const runCodexTurn = async (args: {
codexSessionId: workspace.codexSessionId,
});
const command = workspace.codexSessionId
? commandToShell(
`codex exec resume --json${codexModelFlag(
workspace.claim,
)} --dangerously-bypass-approvals-and-sandbox ${quoteShell(
workspace.codexSessionId,
)} ${quoteShell(prompt)}`,
)
: commandToShell(
`codex exec --json${codexModelFlag(
workspace.claim,
)} --dangerously-bypass-approvals-and-sandbox --cd ${quoteShell(
codexContainerRepo,
)} ${quoteShell(prompt)}`,
);
? [
'codex',
'exec',
'resume',
'--json',
...codexModelArgs(workspace.claim),
'--dangerously-bypass-approvals-and-sandbox',
workspace.codexSessionId,
prompt,
]
: [
'codex',
'exec',
'--json',
...codexModelArgs(workspace.claim),
'--dangerously-bypass-approvals-and-sandbox',
'--cd',
codexContainerRepo,
prompt,
];
const aiEnv = providerEnvironment(workspace.claim, codexContainerWorkspace);
const secretEnv = Object.fromEntries(
workspace.claim.secrets.map((secret) => [secret.name, secret.value]),
@@ -734,12 +741,17 @@ const runCodexTurn = async (args: {
}
},
onStderrLine: async (line) => {
if (line.trim()) {
const trimmed = line.trim();
if (
trimmed &&
trimmed !== 'Reading additional input from stdin...' &&
!trimmed.includes('`[features].codex_hooks` is deprecated')
) {
await appendEvent(
workspace.claim.job._id,
'info',
'plan',
truncate(line, 10_000),
truncate(trimmed, 10_000),
);
}
},
@@ -1034,6 +1046,9 @@ const recordChangedFiles = async (
workspace.repoDir,
workspace.redact,
);
const signature = JSON.stringify({ diff, changes });
if (signature === workspace.lastRecordedDiffSignature) return;
workspace.lastRecordedDiffSignature = signature;
for (const change of changes) {
await recordWorkspaceChange({
jobId: workspace.claim.job._id,
@@ -1235,7 +1250,9 @@ const runClaim = async (claim: Claim) => {
});
await appendEvent(jobId, 'info', 'plan', 'Interactive workspace is ready.');
await sendWorkspaceMessage(jobId, systemPromptForJob(claim));
await sendWorkspaceMessage(jobId, systemPromptForJob(claim), {
recordUserMessage: false,
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
await appendEvent(
@@ -1428,18 +1445,24 @@ export const replyToInteraction = async (
return { success: true };
};
export const sendWorkspaceMessage = async (jobId: string, prompt: string) => {
export const sendWorkspaceMessage = async (
jobId: string,
prompt: string,
options: { recordUserMessage?: boolean } = {},
) => {
const workspace = resolveWorkspace(jobId);
const { claim, redact } = workspace;
if (workspace.agentTurnActive) {
throw new Error('Wait for the current agent turn to finish or abort it.');
}
await appendMessage({
jobId: claim.job._id,
role: 'user',
status: 'completed',
content: prompt,
});
if (options.recordUserMessage ?? true) {
await appendMessage({
jobId: claim.job._id,
role: 'user',
status: 'completed',
content: prompt,
});
}
await appendEvent(claim.job._id, 'info', 'plan', 'Sending message to agent.');
let assistantMessageId: Id<'agentJobMessages'> | undefined;