Complete implementation of Agentic Context Engineering (ACE) framework: Core modules (optimization_engine/context/): - playbook.py: AtomizerPlaybook with helpful/harmful scoring - reflector.py: AtomizerReflector for insight extraction - session_state.py: Context isolation (exposed/isolated state) - feedback_loop.py: Automated learning from trial results - compaction.py: Long-session context management - cache_monitor.py: KV-cache optimization tracking - runner_integration.py: OptimizationRunner integration Dashboard integration: - context.py: 12 REST API endpoints for playbook management Tests: - test_context_engineering.py: 44 unit tests - test_context_integration.py: 16 integration tests Documentation: - CONTEXT_ENGINEERING_REPORT.md: Comprehensive implementation report - CONTEXT_ENGINEERING_API.md: Complete API reference - SYS_17_CONTEXT_ENGINEERING.md: System protocol - Updated cheatsheet with SYS_17 quick reference - Enhanced bootstrap (00_BOOTSTRAP_V2.md) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
124 lines
2.5 KiB
Python
124 lines
2.5 KiB
Python
"""
|
|
Atomizer Context Engineering Module
|
|
|
|
Implements state-of-the-art context engineering for LLM-powered optimization.
|
|
Based on the ACE (Agentic Context Engineering) framework.
|
|
|
|
Components:
|
|
- Playbook: Structured knowledge store with helpful/harmful tracking
|
|
- Reflector: Analyzes optimization outcomes to extract insights
|
|
- SessionState: Context isolation with exposed/isolated separation
|
|
- CacheMonitor: KV-cache optimization for cost reduction
|
|
- FeedbackLoop: Automated learning from execution
|
|
- Compaction: Long-running session context management
|
|
|
|
Usage:
|
|
from optimization_engine.context import (
|
|
AtomizerPlaybook,
|
|
AtomizerReflector,
|
|
AtomizerSessionState,
|
|
FeedbackLoop,
|
|
CompactionManager
|
|
)
|
|
|
|
# Load or create playbook
|
|
playbook = AtomizerPlaybook.load(path)
|
|
|
|
# Create feedback loop for learning
|
|
feedback = FeedbackLoop(playbook_path)
|
|
|
|
# Process trial results
|
|
feedback.process_trial_result(...)
|
|
|
|
# Finalize and commit learning
|
|
feedback.finalize_study(stats)
|
|
"""
|
|
|
|
from .playbook import (
|
|
AtomizerPlaybook,
|
|
PlaybookItem,
|
|
InsightCategory,
|
|
get_playbook,
|
|
save_playbook,
|
|
)
|
|
|
|
from .reflector import (
|
|
AtomizerReflector,
|
|
OptimizationOutcome,
|
|
InsightCandidate,
|
|
ReflectorFactory,
|
|
)
|
|
|
|
from .session_state import (
|
|
AtomizerSessionState,
|
|
ExposedState,
|
|
IsolatedState,
|
|
TaskType,
|
|
get_session,
|
|
set_session,
|
|
clear_session,
|
|
)
|
|
|
|
from .cache_monitor import (
|
|
ContextCacheOptimizer,
|
|
CacheStats,
|
|
ContextSection,
|
|
StablePrefixBuilder,
|
|
get_cache_optimizer,
|
|
)
|
|
|
|
from .feedback_loop import (
|
|
FeedbackLoop,
|
|
FeedbackLoopFactory,
|
|
)
|
|
|
|
from .compaction import (
|
|
CompactionManager,
|
|
ContextEvent,
|
|
EventType,
|
|
ContextBudgetManager,
|
|
)
|
|
|
|
__all__ = [
|
|
# Playbook
|
|
"AtomizerPlaybook",
|
|
"PlaybookItem",
|
|
"InsightCategory",
|
|
"get_playbook",
|
|
"save_playbook",
|
|
|
|
# Reflector
|
|
"AtomizerReflector",
|
|
"OptimizationOutcome",
|
|
"InsightCandidate",
|
|
"ReflectorFactory",
|
|
|
|
# Session State
|
|
"AtomizerSessionState",
|
|
"ExposedState",
|
|
"IsolatedState",
|
|
"TaskType",
|
|
"get_session",
|
|
"set_session",
|
|
"clear_session",
|
|
|
|
# Cache Monitor
|
|
"ContextCacheOptimizer",
|
|
"CacheStats",
|
|
"ContextSection",
|
|
"StablePrefixBuilder",
|
|
"get_cache_optimizer",
|
|
|
|
# Feedback Loop
|
|
"FeedbackLoop",
|
|
"FeedbackLoopFactory",
|
|
|
|
# Compaction
|
|
"CompactionManager",
|
|
"ContextEvent",
|
|
"EventType",
|
|
"ContextBudgetManager",
|
|
]
|
|
|
|
__version__ = "1.0.0"
|