fix(models): retain upstream identity and pause strict mismatches
This commit is contained in:
@@ -391,6 +391,8 @@ export class Runtime {
|
||||
const captured = redacted === decoded ? raw : Buffer.from(redacted, 'utf8');
|
||||
const artifact = this.store.artifactStore.write(session, run.record, captured, { kind: progress.streamCapture !== undefined ? 'model-stream-response' : 'model-http-response', mediaType: 'text/plain' });
|
||||
this.store.core.artifact.set(artifact.id, artifact);
|
||||
if (progress.modelIdentity) progress.modelIdentity.responseSource = { artifactId: artifact.id, sha256: artifact.sha256, sessionId: session.id,
|
||||
scope: progress.streamCapture !== undefined ? 'sse-stream' : 'http-body' };
|
||||
if (progress.upstream) Object.assign(progress.upstream, { artifactId: artifact.id, artifactSha256: artifact.sha256,
|
||||
artifactScope: progress.streamCapture !== undefined ? 'sse-stream' : 'http-body', sessionId: session.id });
|
||||
if (progress.upstream?.capture) Object.assign(progress.upstream.capture, { retention: 'artifact', storedBytes: artifact.bytes });
|
||||
@@ -408,6 +410,7 @@ export class Runtime {
|
||||
if (progress.stream) requestEvent.stream = { ...requestEvent.stream, ...progress.stream, status: progress.stream.terminal ? 'completed' : 'receiving' };
|
||||
if (progress.phase === 'failed' && requestEvent.stream) requestEvent.stream.status = 'incomplete';
|
||||
if (progress.connectionId) { requestEvent.connectionId = progress.connectionId; requestEvent.modelAttemptId = progress.modelAttemptId; requestEvent.actualModel = progress.model; }
|
||||
if (progress.modelIdentity) requestEvent.modelIdentity = progress.modelIdentity;
|
||||
requestEvent.label = progress.switching ? '正在切换模型池连接' : progress.phase === 'retrying' ? '正在重试模型连接' : progress.phase === 'completed' ? '模型响应已收到' : progress.phase === 'failed' ? '模型连接失败' : '请求模型服务';
|
||||
if (externalEngine) requestEvent.label = progress.phase === 'completed' ? '引擎原结果已收到' : '受控引擎执行';
|
||||
requestEvent.output = progress.phase === 'retrying' ? '第 ' + progress.attempt + ' 次请求失败,将自动重试(最多 ' + progress.maxAttempts + ' 次)。'
|
||||
@@ -440,6 +443,7 @@ export class Runtime {
|
||||
}
|
||||
try { checkBudget(run.record,task); }
|
||||
catch(budget){
|
||||
if(error.diagnostic?.kind==='model_identity') { error.diagnostic.budgetStopReason=budget.reason; throw error; }
|
||||
if(budget instanceof BudgetExceeded&&error.diagnostic)budget.contextBudget={modelFailure:structuredClone(error.diagnostic)};
|
||||
throw budget;
|
||||
}
|
||||
@@ -579,7 +583,8 @@ export class Runtime {
|
||||
session.status = 'paused';
|
||||
this.store.message(session, 'system', budget?.message ?? '任务已停止,执行记录已保存。');
|
||||
} else {
|
||||
session.status = 'failed';
|
||||
session.status = error.diagnostic?.kind === 'model_identity' ? 'paused' : 'failed';
|
||||
if (error.diagnostic?.kind === 'model_identity') run.stopReason = 'model_identity';
|
||||
const diagnostic = error.diagnostic ?? { source: 'workbench', origin: 'local', stage: 'agent_loop', kind: 'runtime',
|
||||
title: '工作台任务需要处理', message: this.provider.redact(error.message ?? String(error)), occurredAt: now() };
|
||||
session.lastFailure = { ...diagnostic, runId: run.id };
|
||||
|
||||
Reference in New Issue
Block a user