BigPizzaV3/CodexPlusPlus · error · Error
API 未能生成本批整理结果
Error message
API 未能生成本批整理结果
What it means
completionText() throws this when the provider refused to produce content: finish_reason==='content_filter' or the message carries a refusal field. The batch result is unusable, so the script aborts the batch instead of storing filtered/refused output.
Solutions
- Review the conversation content for policy-triggering material
- Adjust safety/content-filter settings on the provider account if available
- Try a different model or provider with more permissive filtering
- Split the batch to isolate and exclude the problematic messages
Defensive patterns
Strategy: try-catch
Validate before calling
const refused = body?.choices?.[0]?.finish_reason==='content_filter' || !!body?.choices?.[0]?.message?.refusal;
Try / catch
try{ await organizeLong(...) }catch(e){ if(e.message==='API 未能生成本批整理结果'){ notifyContentBlocked(); splitBatchAndExcludeFlagged(); } } Prevention
- Know your provider's content policy
- Adjust safety settings where available
- Split sensitive conversations into smaller batches
When it happens
Trigger: choices[0].finish_reason==='content_filter', or choices[0].message.refusal is set — the provider's safety layer blocked generation.
Common situations: Conversation content triggered the provider's content policy; safety settings too strict on the account; certain flagged topics in the messages being organized.
Related errors
- API 未能生成本批整理结果
- API 输出达到长度上限,本批未提交;请使用输出容量更大的模型
- API 未返回有效的 choices[0].message.content,请确认兼容 Chat Completions
- 历史轮次分页游标重复
- 历史轮次接口返回格式无效
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/3204c47fec2874fe.
Report an issue: GitHub.
Appendix: source
Thrown at tools/conversation-canvas/public/canvas.user.js:698
size+=part.value.byteLength;if(size>4*1024*1024)throw Object.assign(Error('API 响应超过大小限制'),{canvasApiLocal:true});
const text=decoder.decode(part.value,{stream:true});
if(!sse){raw+=text;if(/^\s*(data:|:)/.test(raw)){sse=true;buffer=raw;raw='';}}
else buffer+=text;
if(sse){let end;while((end=buffer.indexOf('\n'))>=0){consume(buffer.slice(0,end).replace(/\r$/,''));buffer=buffer.slice(end+1);}}
progress({bytes:size,chars:content.length});if(done)break;
}
const tail=decoder.decode();if(sse){buffer+=tail;if(buffer.trim())consume(buffer.replace(/\r$/,''));
if(!done&&!finish)throw Object.assign(Error('API 流式连接提前结束,本批未提交'),{canvasApiLocal:true,retryable:true});
return {choices:[{finish_reason:finish,message:{content}}]};
}
try{return JSON.parse(raw+tail);}catch{throw Object.assign(Error('API 返回的不是 JSON,请检查 API 地址'),{canvasApiLocal:true});}
}finally{void reader.cancel().catch(()=>{});try{reader.releaseLock();}catch{}}
}
function completionText(body){
const choice=body?.choices?.[0];
if(choice?.finish_reason==='length')throw Error('API 输出达到长度上限,本批未提交;请使用输出容量更大的模型');
if(choice?.finish_reason==='content_filter'||choice?.message?.refusal)throw Error('API 未能生成本批整理结果');
const content=choice?.message?.content;
const value=typeof content==='string'?content:Array.isArray(content)?content.filter(p=>p?.type==='text').map(p=>p.text||'').join(''):'';
if(!value.trim())throw Error('API 未返回有效的 choices[0].message.content,请确认兼容 Chat Completions');
return value;
}
function waitForApi(promise,signal){
signal?.throwIfAborted();
if(!signal)return promise;
return new Promise((resolve,reject)=>{
const abort=()=>{signal.removeEventListener('abort',abort);reject(signal.reason||new DOMException('Aborted','AbortError'));};
signal.addEventListener('abort',abort,{once:true});
promise.then(value=>{signal.removeEventListener('abort',abort);resolve(value);},error=>{signal.removeEventListener('abort',abort);reject(error);});
});
}
function createApiOrganizer({request,timeoutMs=300000,maxRetries=2,retryDelayMs=2000}){
const requests=new Map();View on GitHub (pinned to b1ed92e5e4)