feat: add fail-closed Aider development skill

This commit is contained in:
john
2026-07-24 19:48:04 +08:00
parent 1c82b34ad9
commit be9c25f1d0
15 changed files with 320 additions and 7 deletions
+3 -2
View File
@@ -174,7 +174,7 @@ function withAgentRunValidationMetadata(
function prepareAgentRunUserMessage(message: Message, options: AgentRunCreateOptions): Message {
const normalized = normalizeUserMessageForApi(message);
const withValidation = withAgentRunValidationMetadata(normalized, options.validation);
const withRunMetadata = options.forceDeepReasoning
const withRunMetadata = options.forceDeepReasoning || options.executor
? {
...withValidation,
metadata: {
@@ -186,7 +186,8 @@ function prepareAgentRunUserMessage(message: Message, options: AgentRunCreateOpt
? withValidation.metadata.memindRun
: {}
),
forceDeepReasoning: true,
...(options.forceDeepReasoning ? { forceDeepReasoning: true } : {}),
...(options.executor ? { executor: options.executor } : {}),
},
},
}
+7 -1
View File
@@ -51,7 +51,10 @@ import type {
} from '../types';
import { buildContextPrefix } from '../utils/mindspaceChatContext';
import { buildUserAddressPrefix } from '../utils/userAddress';
import { buildAutoChatSkillPrefix } from '../../chat-skills.mjs';
import {
AIDER_DEVELOPMENT_SKILL_NAME,
buildAutoChatSkillPrefix,
} from '../../chat-skills.mjs';
import {
reconcileSessionEventRequestContext,
resolvePostAgentRunChatState,
@@ -1473,8 +1476,11 @@ export function useTKMindChat(
try {
const pageDataDevTaskType = resolvePageDataDevTaskType(trimmed);
const requiresAider = options?.selectedChatSkill === AIDER_DEVELOPMENT_SKILL_NAME;
const runOptions = resolveAgentRunOptions(trimmed, {
taskType: pageDataDevTaskType ?? 'h5_chat_code_task',
forceCode: requiresAider,
requiredExecutor: requiresAider ? 'aider' : undefined,
userId: userRef.current?.id ?? null,
requestId,
mindspaceContext: options?.mindspaceContext ?? null,
+6 -1
View File
@@ -3,6 +3,7 @@ import type { MindSpaceChatContext, AgentCodeRunClientPolicy } from '../types';
export type AgentRunCreateOptions = {
toolMode?: 'chat' | 'code';
taskType?: string | null;
executor?: 'aider' | 'openhands';
forceDeepReasoning?: boolean;
validation?: AgentRunValidation | null;
validationInstruction?: string | null;
@@ -299,6 +300,7 @@ export function resolveAgentRunOptions(
}: {
taskType?: string;
forceCode?: boolean;
requiredExecutor?: 'aider' | 'openhands';
allowAutodetect?: boolean;
allowPageDataDevAutodetect?: boolean;
userId?: string | null;
@@ -313,15 +315,17 @@ export function resolveAgentRunOptions(
const effectiveTaskType = pageDataDevTaskType ?? taskType;
const shouldUseDeepReasoning =
forceCode ||
Boolean(requiredExecutor) ||
Boolean(pageDataDevTaskType) ||
DEEP_REASONING_TASK_PATTERNS.some((pattern) => pattern.test(normalizedText));
if (!agentCodeRunsEnabledForUser(userId)) {
if (!agentCodeRunsEnabledForUser(userId) && !requiredExecutor) {
return shouldUseDeepReasoning ? { forceDeepReasoning: true, taskType: effectiveTaskType } : {};
}
const shouldUseCode =
forceCode ||
Boolean(requiredExecutor) ||
Boolean(pageDataDevTaskType) ||
(allowAutodetect && CODE_TASK_PATTERNS.some((pattern) => pattern.test(normalizedText)));
if (!shouldUseCode) {
@@ -339,6 +343,7 @@ export function resolveAgentRunOptions(
return {
toolMode: 'code',
taskType: effectiveTaskType,
...(requiredExecutor ? { executor: requiredExecutor } : {}),
forceDeepReasoning: true,
validation: mergeAgentRunValidationFiles(receipt.validation, taskValidation.validation),
validationInstruction: `${receipt.instruction}${taskValidation.instruction}`,