(retryContext: Record<string, unknown> | null)
| 1123 | } |
| 1124 | |
| 1125 | function buildRetryDeveloperInstructions(retryContext: Record<string, unknown> | null): string { |
| 1126 | if (!retryContext) { |
| 1127 | return ''; |
| 1128 | } |
| 1129 | const stoppedAt = typeof retryContext.stoppedAt === 'number' |
| 1130 | ? new Date(retryContext.stoppedAt).toISOString() |
| 1131 | : null; |
| 1132 | const threadId = typeof retryContext.threadId === 'string' && retryContext.threadId.trim() |
| 1133 | ? retryContext.threadId.trim() |
| 1134 | : null; |
| 1135 | const interruptedTurnIds = Array.isArray(retryContext.interruptedTurnIds) |
| 1136 | ? retryContext.interruptedTurnIds |
| 1137 | .map((entry) => (typeof entry === 'string' ? entry.trim() : '')) |
| 1138 | .filter(Boolean) |
| 1139 | : []; |
| 1140 | const pendingApprovalCount = typeof retryContext.pendingApprovalCount === 'number' |
| 1141 | ? retryContext.pendingApprovalCount |
| 1142 | : 0; |
| 1143 | const interruptErrors = Array.isArray(retryContext.interruptErrors) |
| 1144 | ? retryContext.interruptErrors |
| 1145 | .map((entry) => (typeof entry === 'string' ? entry.trim() : '')) |
| 1146 | .filter(Boolean) |
| 1147 | : []; |
| 1148 | const lines = [ |
| 1149 | 'Retry context from CodexBridge:', |
| 1150 | '- This request is being retried on the same Codex thread after the previous attempt was manually stopped.', |
| 1151 | ]; |
| 1152 | if (threadId) { |
| 1153 | lines.push(`- Thread id: ${threadId}`); |
| 1154 | } |
| 1155 | if (stoppedAt) { |
| 1156 | lines.push(`- Stop requested at: ${stoppedAt}`); |
| 1157 | } |
| 1158 | if (interruptedTurnIds.length > 0) { |
| 1159 | lines.push(`- Interrupted turn ids: ${interruptedTurnIds.join(', ')}`); |
| 1160 | } |
| 1161 | if (pendingApprovalCount > 0) { |
| 1162 | lines.push(`- Pending approval requests discarded during stop: ${pendingApprovalCount}`); |
| 1163 | } |
| 1164 | if (interruptErrors.length > 0) { |
| 1165 | lines.push(`- Interrupt errors observed: ${interruptErrors.join(' | ')}`); |
| 1166 | } |
| 1167 | lines.push('- Continue from the existing thread context when it helps, but answer the user request fully from scratch if needed.'); |
| 1168 | return lines.join('\n'); |
| 1169 | } |
| 1170 | |
| 1171 | function buildExplicitPluginDeveloperInstructions(targets: Record<string, unknown>[]): string { |
| 1172 | if (!Array.isArray(targets) || targets.length === 0) { |
no outgoing calls
no test coverage detected