feat(models): execute Responses and validated streams with capability routing
This commit is contained in:
@@ -284,12 +284,16 @@ export class Runtime {
|
||||
planned.record.requestAttempts = Math.max(planned.record.requestAttempts, progress.attempt ?? 0);
|
||||
stepRecord.modelAttempts = Math.max(stepRecord.modelAttempts, progress.attempt ?? 0);
|
||||
requestEvent.phase = progress.phase; requestEvent.attempts = progress.attempt;
|
||||
if (progress.streaming) requestEvent.stream = { status: 'receiving', protocol: progress.protocol, sequence: progress.streamSequence,
|
||||
bytes: progress.streamBytes, textCharacters: progress.textCharacters, textPreview: this.provider.redact(progress.textPreview ?? '').slice(0, 8000), toolFragments: progress.toolFragments };
|
||||
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; }
|
||||
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 + ' 次)。'
|
||||
: progress.phase === 'completed' ? '模型响应已收到;工具请求将在校验后执行。'
|
||||
: progress.diagnostic?.message ?? '正在等待模型响应。';
|
||||
: progress.streaming ? '正在接收模型输出,工具参数完整核对前不会执行。' : progress.diagnostic?.message ?? '正在等待模型响应。';
|
||||
if (externalEngine) requestEvent.output = progress.phase === 'completed' ? '原引擎工具请求或最终输出已返回,后续按所属任务核验。' : '等待所属引擎;实际模型尝试另有记录。';
|
||||
if (progress.diagnostic) requestEvent.diagnostic = progress.diagnostic;
|
||||
if (progress.durationMs !== undefined) requestEvent.durationMs = progress.durationMs;
|
||||
@@ -305,6 +309,7 @@ export class Runtime {
|
||||
planned.record.workerUsageAccounted = true; this.store.save(session); responseAccounted = true;
|
||||
}
|
||||
} catch (error) {
|
||||
if (requestEvent?.stream && requestEvent.stream.status !== 'completed') { requestEvent.stream.status = signal.aborted ? 'interrupted' : 'incomplete'; requestEvent.phase = signal.aborted ? 'interrupted' : 'failed'; requestEvent.finishedAt = now(); }
|
||||
this.requestPlanner().finish(session, planned.record, { error: Object.assign(new Error(this.provider.redact(error.message ?? String(error))), { name: signal.aborted ? 'AbortError' : error.name }), attempts: planned.record.requestAttempts });
|
||||
if (run.worker && requestStarted && !responseAccounted) {
|
||||
this.store.recordResponse(session, run.record, null, planned.record.estimatedInputTokens + config.maxOutputTokens);
|
||||
|
||||
Reference in New Issue
Block a user