|
118 | 118 | // - DefaultStrategy: Balanced approach with standard limits |
119 | 119 | // - ConservativeStrategy: Stops earlier to prevent excessive token usage |
120 | 120 | // - AggressiveStrategy: Continues more aggressively for batch operations |
| 121 | +// - LLMJudgeStrategy: Uses an LLM to make intelligent auto-continue decisions |
121 | 122 | // |
122 | 123 | // Custom strategies can be implemented by implementing the Strategy interface. |
123 | 124 | // |
| 125 | +// # LLM Judge Strategy |
| 126 | +// |
| 127 | +// The LLMJudgeStrategy provides intelligent auto-continue decisions by: |
| 128 | +// |
| 129 | +// 1. Checking for repetitive patterns (loops) in recent messages |
| 130 | +// 2. Using an LLM to evaluate whether continuation is needed |
| 131 | +// 3. Applying model-specific decision logic (Qwen 3, Mistral, etc.) |
| 132 | +// 4. Falling back to pattern matching on any LLM failure |
| 133 | +// |
| 134 | +// Configuration options: |
| 135 | +// |
| 136 | +// - EnableLLMAutoContinueJudge: Enable/disable the LLM judge |
| 137 | +// - LLMAutoContinueJudgeTimeout: Maximum time to wait for LLM response (default: 15s) |
| 138 | +// - LLMAutoContinueJudgeTokenLimit: Context limit sent to LLM judge (default: 1000 tokens) |
| 139 | +// |
| 140 | +// Example usage: |
| 141 | +// |
| 142 | +// config := loop.DefaultConfig() |
| 143 | +// config.EnableLLMAutoContinueJudge = true |
| 144 | +// config.LLMAutoContinueJudgeTimeout = 15 * time.Second |
| 145 | +// config.LLMAutoContinueJudgeTokenLimit = 1000 |
| 146 | +// factory := loop.NewStrategyFactory(config) |
| 147 | +// strategy := factory.CreateWithLLMJudge("llm-judge", config, llmClient, modelID, session) |
| 148 | +// |
| 149 | +// The LLM judge automatically falls back to pattern matching if: |
| 150 | +// - The LLM client is not available |
| 151 | +// - The model ID is empty |
| 152 | +// - The LLM call times out |
| 153 | +// - The LLM returns an invalid response |
| 154 | +// - Auto-continue is disabled in the config |
| 155 | +// |
124 | 156 | // # Testing |
125 | 157 | // |
126 | 158 | // The package includes mock implementations for testing: |
|
0 commit comments