fix(agent): cancel vision failover when the task stops
This commit is contained in:
parent
b17ccfdeed
commit
0e960b1723
@ -169,7 +169,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
if (!model) throw new AgentRunError("Agent 模型暂不可用", 503);
|
||||
const visionModel = model;
|
||||
const withModel = createAgentVisionExecutor(candidates, agentModelCircuitStore, getLanguageModelById);
|
||||
const executeVisionModel = createAgentVisionExecutor(candidates, agentModelCircuitStore, getLanguageModelById);
|
||||
// Validate the user's image choice independently of the Agent planning model.
|
||||
if (body.selectedImageModel) {
|
||||
const images = await getStyleProImageModelEntries();
|
||||
@ -269,7 +269,9 @@ export async function POST(request: Request) {
|
||||
const emit = (type: string, data: unknown) => writer.write({ type, data, ...(type === "data-canvasAgentRun" ? { transient: true } : {}) } as never);
|
||||
let cancelled = false;
|
||||
let leaseLost = false;
|
||||
let activeModelController: AbortController | null = null;
|
||||
const activeModelController = new AbortController();
|
||||
const withModel: typeof executeVisionModel = (execute, signal) => executeVisionModel(execute,
|
||||
signal ? AbortSignal.any([signal, activeModelController.signal]) : activeModelController.signal);
|
||||
const heartbeat = setInterval(() => {
|
||||
void heartbeatAgentRun(run)
|
||||
.then((current) => {
|
||||
@ -337,7 +339,6 @@ export async function POST(request: Request) {
|
||||
definitions: tools.definitions, executable: tools.executable, emit,
|
||||
imagePreferences: snapshot.imagePreferences });
|
||||
const gateway = await createZcodeModelGateway(configured, undefined, candidates);
|
||||
activeModelController = new AbortController();
|
||||
const status = await runZcodeCanvasTask({
|
||||
runId: run.id, snapshot, definitions: tools.definitions,
|
||||
instructions: (isVideo ? videoRuntimeSystemPrompt : canvasRuntimeSystemPrompt)(snapshot.objective, snapshot.summary, snapshot.inputs.map(input => input.text), context),
|
||||
@ -401,7 +402,8 @@ export async function POST(request: Request) {
|
||||
projectId,
|
||||
model: visionModel || model,
|
||||
supportsVision: Boolean(visionModel),
|
||||
withModel,
|
||||
withModel,
|
||||
signal: activeModelController.signal,
|
||||
}),
|
||||
});
|
||||
const finalText = snapshot.message;
|
||||
|
||||
@ -108,6 +108,7 @@ export async function verifyCanvasAgentResults(params: {
|
||||
supportsVision: boolean;
|
||||
withModel?: AgentVisionExecutor;
|
||||
reviewPorts?: RuntimeReviewPorts;
|
||||
signal?: AbortSignal;
|
||||
}) {
|
||||
const { snapshot } = params;
|
||||
const calls = snapshot.calls;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user