|
|
@@ -707,28 +707,6 @@ export class WorkspaceRuntime extends WorkspaceScheduler {
|
|
|
} else {
|
|
|
if (opened.running) throw new HttpError(409, '上游会话仍在运行', 'session_busy')
|
|
|
this.nodes.requireSource(owner, agent)
|
|
|
- if (agent.modelSettings !== undefined) {
|
|
|
- const entry = { method: 'bot.model-settings', agentId: agent.id, runId: run.runId, taskId: run.conversationTaskId }
|
|
|
- const snapshot = { revision: agent.revision, settings: agent.modelSettings }
|
|
|
- this.inspector?.record(owner, c.id, { ...entry, direction: 'request', data: snapshot })
|
|
|
- try {
|
|
|
- const resolution = await resolveBotModelSettings(target, agent.profile, agent.modelSettings)
|
|
|
- const confirmed = agent.modelSettingsConfirmation === botModelTarget(resolution.effective)
|
|
|
- if (resolution.confirmationMessage && !confirmed) throw new HttpError(409, '此模型需要确认,请打开 Bot 个人资料保存模型设置。', 'model_confirmation_required')
|
|
|
- await applyBotModelSettings((method, params) => gateway.rpc(method, params), runtimeId, resolution.effective, confirmed, opened.info)
|
|
|
- this.inspector?.record(owner, c.id, { ...entry, direction: 'response', data: { ...snapshot, applied: true, effective: resolution.effective } })
|
|
|
- } catch (error) {
|
|
|
- // Context-dependent native warnings cannot be known from the model
|
|
|
- // catalogue. Bring them back to the profile's existing save flow.
|
|
|
- if (error instanceof BotModelConfirmationError) {
|
|
|
- const latest = this.store.require<Agent>(owner, 'agent', agent.id)
|
|
|
- if (latest.revision === agent.revision) this.store.put(owner, 'agent', latest.id, { ...latest,
|
|
|
- modelSettingsPendingConfirmation: { target: error.target, message: error.confirmationMessage } })
|
|
|
- }
|
|
|
- this.inspector?.record(owner, c.id, { ...entry, direction: 'response', data: { ...snapshot, applied: false, error: error instanceof Error ? error.message : '模型设置应用失败' } })
|
|
|
- throw error
|
|
|
- }
|
|
|
- }
|
|
|
const team=botCapabilities.tools&&!agent.temporaryGoalId&&!agent.remoteAgentId&&!this.store.require<Run>(owner,'run',run.runId).assignmentId
|
|
|
const cloud=!!this.cloud?.selected(owner,agent)
|
|
|
const plugins=!!this.plugins?.selected(owner,agent)
|
|
|
@@ -779,6 +757,30 @@ export class WorkspaceRuntime extends WorkspaceScheduler {
|
|
|
await toolLease.bind();if(settled)return await completion
|
|
|
}
|
|
|
await applyWorkingDirectory((method, params) => gateway.rpc(method, params), runtimeId, cwd, undefined, opened.info?.cwd)
|
|
|
+ // Binding initializes cold Hermes sessions; its persisted runtime can overwrite
|
|
|
+ // pre-build config acknowledgements. Apply Bot settings only after that boundary.
|
|
|
+ if (agent.modelSettings !== undefined) {
|
|
|
+ const entry = { method: 'bot.model-settings', agentId: agent.id, runId: run.runId, taskId: run.conversationTaskId }
|
|
|
+ const snapshot = { revision: agent.revision, settings: agent.modelSettings }
|
|
|
+ this.inspector?.record(owner, c.id, { ...entry, direction: 'request', data: snapshot })
|
|
|
+ try {
|
|
|
+ const resolution = await resolveBotModelSettings(target, agent.profile, agent.modelSettings)
|
|
|
+ const confirmed = agent.modelSettingsConfirmation === botModelTarget(resolution.effective)
|
|
|
+ if (resolution.confirmationMessage && !confirmed) throw new HttpError(409, '此模型需要确认,请打开 Bot 个人资料保存模型设置。', 'model_confirmation_required')
|
|
|
+ await applyBotModelSettings((method, params) => gateway.rpc(method, params), runtimeId, resolution.effective, confirmed)
|
|
|
+ this.inspector?.record(owner, c.id, { ...entry, direction: 'response', data: { ...snapshot, applied: true, effective: resolution.effective } })
|
|
|
+ } catch (error) {
|
|
|
+ // Context-dependent native warnings cannot be known from the model
|
|
|
+ // catalogue. Bring them back to the profile's existing save flow.
|
|
|
+ if (error instanceof BotModelConfirmationError) {
|
|
|
+ const latest = this.store.require<Agent>(owner, 'agent', agent.id)
|
|
|
+ if (latest.revision === agent.revision) this.store.put(owner, 'agent', latest.id, { ...latest,
|
|
|
+ modelSettingsPendingConfirmation: { target: error.target, message: error.confirmationMessage } })
|
|
|
+ }
|
|
|
+ this.inspector?.record(owner, c.id, { ...entry, direction: 'response', data: { ...snapshot, applied: false, error: error instanceof Error ? error.message : '模型设置应用失败' } })
|
|
|
+ throw error
|
|
|
+ }
|
|
|
+ }
|
|
|
const trigger = this.store.require<Message>(owner, 'message', run.messageId)
|
|
|
const attachmentRefs: string[] = []
|
|
|
for (const file of trigger.attachments) {
|