forked from bai/curriculum-project-hub
feat(hub): raise agent turns/time limits and notify teachers on failure
Defaults and silo env go to 150 turns / 1800s wall clock. Run completion appends a clear Feishu notice for max-turns, timeout, and other failures (partial answer kept). Startup process-restart kills notify the bound chat. Release v0.0.38.
This commit is contained in:
@@ -40,6 +40,7 @@ import { createAgentSdkStderrSink } from "../agent/diagnostics.js";
|
||||
import { InactiveOrganizationError, lockActiveOrganization } from "../org/status.js";
|
||||
import { StreamingAgentCard } from "./card/streaming-card.js";
|
||||
import { createFileDeliveryMcpServer } from "./fileDeliveryTool.js";
|
||||
import { appendTeacherNotice, teacherFacingRunOutcome } from "./runOutcomeNotice.js";
|
||||
import { readFeishuContext } from "./read.js";
|
||||
import { MessageBatcher, messageBatchKey, type MessageBatcherOptions } from "./messageBatcher.js";
|
||||
import { ApprovalManager } from "./approval.js";
|
||||
@@ -598,13 +599,24 @@ export function makeTriggerHandler(deps: TriggerDeps): TriggerHandler {
|
||||
agentExecution
|
||||
.then(async (result) => {
|
||||
const interrupted = result.status === "interrupted" && !wallTimeExceeded;
|
||||
const finalText =
|
||||
const hasPartialText = result.text.trim() !== "";
|
||||
const outcome = teacherFacingRunOutcome({
|
||||
wallTimeExceeded,
|
||||
interrupted,
|
||||
resultStatus: result.status,
|
||||
resultError: result.error,
|
||||
maxTurns: runPolicy.maxTurns,
|
||||
maxRunSeconds: runPolicy.maxRunSeconds,
|
||||
hasPartialText,
|
||||
});
|
||||
const baseText =
|
||||
result.text !== ""
|
||||
? result.text
|
||||
: result.status === "failed" && result.error !== undefined
|
||||
: result.status === "failed" && result.error !== undefined && outcome.notice === undefined
|
||||
? `\u5904\u7406\u5931\u8D25: ${result.error}`
|
||||
: result.text;
|
||||
await card.finish(finalText, { interrupted });
|
||||
const finalText = appendTeacherNotice(baseText, outcome.notice);
|
||||
await card.finish(finalText, { interrupted, isError: outcome.isError });
|
||||
const metadataPatch = sessionMetadataPatch(result.sdkSessionId);
|
||||
if (metadataPatch !== null) {
|
||||
await deps.prisma.agentSession.update({
|
||||
@@ -675,7 +687,20 @@ export function makeTriggerHandler(deps: TriggerDeps): TriggerHandler {
|
||||
if (removedProcessingReaction) {
|
||||
await addReaction(rt, msg.message_id, "CrossMark");
|
||||
}
|
||||
await card.fail(e instanceof Error ? e.message : String(e));
|
||||
await card.fail(
|
||||
appendTeacherNotice(
|
||||
"",
|
||||
teacherFacingRunOutcome({
|
||||
wallTimeExceeded: false,
|
||||
interrupted: false,
|
||||
resultStatus: "failed",
|
||||
resultError: e instanceof Error ? e.message : String(e),
|
||||
maxTurns: runPolicy.maxTurns,
|
||||
maxRunSeconds: runPolicy.maxRunSeconds,
|
||||
hasPartialText: false,
|
||||
}).notice ?? `\u274C \u4EFB\u52A1\u5931\u8D25\uFF1A${e instanceof Error ? e.message : String(e)}`,
|
||||
),
|
||||
);
|
||||
try {
|
||||
await deps.prisma.agentRun.update({
|
||||
where: { id: run.id },
|
||||
|
||||
Reference in New Issue
Block a user