Merge pull request #9892 from continuedev/fix/agent-iscomplete-metadata

This commit is contained in:
Nate Sesti 2026-01-25 16:10:06 -08:00 • committed by GitHub
commit 6863397ff1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 1 deletions

View file

@ -1,3 +1,5 @@
import { logger } from "../util/logger.js";
import { Tool } from "./types.js";
export const exitTool: Tool = {
@ -12,7 +14,21 @@ export const exitTool: Tool = {
readonly: false,
isBuiltIn: true,
run: async (): Promise<string> => {
const { gracefulExit } = await import("../util/exit.js");
const { gracefulExit, updateAgentMetadata } = await import(
"../util/exit.js"
);
// Mark agent as complete before exiting
try {
await updateAgentMetadata({ isComplete: true });
} catch (err) {
// Non-critical: log but don't block exit
logger.debug(
"Failed to update completion metadata (non-critical)",
err as any,
);
}
await gracefulExit(1);
return "";
},

View file

@ -6,6 +6,7 @@ import {
AuthenticationRequiredError,
post,
} from "../util/apiClient.js";
import { updateAgentMetadata } from "../util/exit.js";
import { logger } from "../util/logger.js";
import { Tool } from "./types.js";
@ -74,6 +75,18 @@ export const reportFailureTool: Tool = {
errorMessage: trimmedMessage,
});
// Mark agent as complete since it failed
try {
await updateAgentMetadata({ isComplete: true });
logger.debug("Marked agent as complete due to failure");
} catch (metadataErr) {
// Non-critical: log but don't fail the failure report
logger.debug(
"Failed to update completion metadata (non-critical)",
metadataErr as any,
);
}
logger.info(`Failure reported: ${trimmedMessage}`);
return "Failure reported to user.";
} catch (error) {

View file

@ -5,6 +5,7 @@ import {
AuthenticationRequiredError,
post,
} from "../util/apiClient.js";
import { updateAgentMetadata } from "../util/exit.js";
import { logger } from "../util/logger.js";
import { Tool } from "./types.js";
@ -62,6 +63,24 @@ You should use this tool to notify the user whenever the state of your work chan
await post(`agents/${agentId}/status`, { status: args.status });
logger.info(`Status: ${args.status}`);
// If status is DONE or FAILED, mark agent as complete
const normalizedStatus = args.status.toUpperCase();
if (normalizedStatus === "DONE" || normalizedStatus === "FAILED") {
try {
await updateAgentMetadata({ isComplete: true });
logger.debug(
`Marked agent as complete due to status: ${args.status}`,
);
} catch (metadataErr) {
// Non-critical: log but don't fail the status update
logger.debug(
"Failed to update completion metadata (non-critical)",
metadataErr as any,
);
}
}
return `Status set: ${args.status}`;
} catch (error) {
if (error instanceof ContinueError) {