Repository navigation
v0.1.0 - Chain-of-Thought Loop
🧠 Chain-of-Thought Loop
This release introduces a new agentic loop pattern focused on deep reasoning through iterative self-reflection.
What's New
Chain-of-Thought Loop
- New trait:
ChainOfThoughtLoop- Enables progressive reasoning with confidence evaluation - Streaming support: Real-time streaming of reasoning iterations via
chainOfThoughtStream() - Self-reflection: Automatic confidence checks between reasoning cycles
- Full transparency: Shows step-by-step thinking process to users
Supporting Classes
CoTResult- Enhanced result object with reasoning metadataCoTStep- Value object for each reasoning iterationCoTPrompts- Reusable prompt templates for CoT reasoning
Lifecycle Callbacks (6 new callbacks)
onIterationStart- When reasoning iteration beginsonBeforeReasoning- Before LLM reasons through problemonAfterReasoning- After reasoning step completesonReflection- When confidence evaluation occursonLoopComplete- When agent reaches confident answeronMaxIterationsReached- When iteration limit is hit
Plus all standard action callbacks (onBeforeAction, onAfterAction)
Configuration
max_reasoning_iterations- Control iteration limits (default: 5)throw_on_max_iterations- Configure error handling- Environment variable support via
AGENTIC_COT_MAX_ITERATIONS
Documentation
- New tutorial: Streaming Chain-of-Thought Loop
- Complete code examples with backend routes and React frontend
- Comparison tables: CoT vs ReAct vs Plan-Execute
- Best practices and customization guide
- Screenshots demonstrating the UI
Tests
- Comprehensive unit tests with 20+ test cases
- Integration tests with real API calls
- 100% coverage of CoT loop logic
When to Use Chain-of-Thought
Use CoT when:
- ✅ The reasoning process needs to be visible/auditable
- ✅ You need to demonstrate understanding, not just results
- ✅ The problem requires careful, step-by-step analysis
- ✅ Users want to see "how" the agent thinks
- ✅ Confidence in the answer is critical
Quick Example
```php
use Laragentic\Loops\ChainOfThoughtLoop;
class MathAgent implements Agent, HasTools
{
use Promptable, ChainOfThoughtLoop;
public function instructions(): string
{
return 'Think step-by-step. Evaluate your confidence. '
. 'Only answer when you're certain.';
}
}
$result = (new MathAgent)->chainOfThought(
'Which train is faster and by how much?'
);
echo $result->text();
echo "Reasoning iterations: {$result->reasoningIterations}";
```
Breaking Changes
None - fully backward compatible with v0.0.2
Updated Documentation
- README updated with Chain-of-Thought section
- Tutorial links updated
- Configuration documented
- All existing tutorials updated with CoT references
Full Changelog: v0.0.2...v0.1.0