feat(FN-1000): add token cap detection for agent task execution
- Add tokenCap to ProjectSettings with tokenCapEnabled flag, default 500K tokens - Create TokenCapDetector class with usage tracking and cap enforcement - Wire TokenCapDetector into executor agentWork() to auto-fail tasks exceeding cap - Add token cap input fields to Settings Modal dashboard UI - Add comprehensive unit tests for TokenCapDetector (174 lines)
This commit is contained in:
@@ -924,6 +924,11 @@ export interface ProjectSettings {
|
||||
* in their prompts and will not read or write to .fusion/memory.md.
|
||||
* Default: true (enabled for backward compatibility). */
|
||||
memoryEnabled?: boolean;
|
||||
/** Maximum token count before auto-compact triggers. When undefined, compact
|
||||
* only on overflow errors. When set, the engine monitors token usage after
|
||||
* each prompt and proactively compacts context when the token count reaches
|
||||
* this threshold. */
|
||||
tokenCap?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1013,6 +1018,7 @@ export const DEFAULT_PROJECT_SETTINGS: ProjectSettings = {
|
||||
insightExtractionSchedule: "0 2 * * *",
|
||||
insightExtractionMinIntervalMs: 86_400_000,
|
||||
memoryEnabled: true,
|
||||
tokenCap: undefined,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1087,6 +1093,7 @@ export const PROJECT_SETTINGS_KEYS: ReadonlyArray<keyof ProjectSettings> = [
|
||||
"titleSummarizerModelId",
|
||||
"titleSummarizerFallbackProvider",
|
||||
"titleSummarizerFallbackModelId",
|
||||
"tokenCap",
|
||||
"insightExtractionEnabled",
|
||||
"insightExtractionSchedule",
|
||||
"insightExtractionMinIntervalMs",
|
||||
|
||||
Reference in New Issue
Block a user