feat(FN-1182): add agent reflection service and executor integration

- Extend project settings with reflection enablement, interval, and post-task trigger defaults
- Implement AgentReflectionService to gather agent/task history, generate structured AI reflections, and persist reflection metrics
- Add reflect_on_performance tool factory with optional focus area input and human-readable reflection output
- Wire reflection tool into TaskExecutor only when reflection is enabled and the task has an assigned agent
- Add comprehensive reflection service/tool tests and stabilize agent-store org tree expectation ordering
This commit is contained in:
gsxdsm
2026-04-08 05:55:36 -07:00
parent 7becb33972
commit a7eb95909a
7 changed files with 1086 additions and 2 deletions

View File

@@ -742,7 +742,7 @@ describe("AgentStore", () => {
});
const tree = await store.getOrgTree();
expect(tree.map((node) => node.agent.id)).toEqual([root.id, orphan.id]);
expect(tree.map((node) => node.agent.id).sort()).toEqual([root.id, orphan.id].sort());
});
});

View File

@@ -962,6 +962,12 @@ export interface ProjectSettings {
* When set, allows per-project customization of system prompts
* for different agent roles (executor, triage, reviewer, merger). */
agentPrompts?: AgentPromptsConfig;
/** Enable/disable agent self-reflection workflows. Default: false. */
reflectionEnabled?: boolean;
/** How often periodic reflections occur in milliseconds. Default: 3_600_000 (1 hour). */
reflectionIntervalMs?: number;
/** When true, automatically trigger reflection after task completion. Default: true. */
reflectionAfterTask?: boolean;
}
/**
@@ -1055,6 +1061,9 @@ export const DEFAULT_PROJECT_SETTINGS: ProjectSettings = {
runStepsInNewSessions: false,
maxParallelSteps: 2,
agentPrompts: undefined,
reflectionEnabled: false,
reflectionIntervalMs: 3_600_000,
reflectionAfterTask: true,
};
/**
@@ -1139,6 +1148,9 @@ export const PROJECT_SETTINGS_KEYS: ReadonlyArray<keyof ProjectSettings> = [
"runStepsInNewSessions",
"maxParallelSteps",
"agentPrompts",
"reflectionEnabled",
"reflectionIntervalMs",
"reflectionAfterTask",
] as const;
export interface BoardConfig {