LeoYeAI/agent-master-skills / skills/agent-mode-upgrades
agentic-loop-upgrade
FlaggedEnhanced agentic loop with planning, parallel execution, confidence gates, semantic error recovery, and observable state machine. Includes Mode dashboard UI for easy configuration.
src/index.ts
View on GitHub/**
* Enhanced Agentic Loop for OpenClaw
*
* A comprehensive upgrade to the agent loop with:
* - Persistent plan state across conversation turns
* - Automatic step completion detection
* - Tool interception with timed approval gates
* - Automatic retry with alternative approaches
* - Context summarization when history grows long
* - Checkpoint/restore for long-running tasks
*
* @module @openclaw/enhanced-loop
*/
// ============================================================================
// Main Orchestrator (recommended entry point)
// ============================================================================
export {
EnhancedLoopOrchestrator,
createOrchestrator,
parsePlanBlock,
hasPlanBlock,
type OrchestratorConfig,
type OrchestratorCallbacks,
type ToolExecutionResult,
type PlanBlockData,
} from "./orchestrator.js";
// ============================================================================
// LLM Caller
// ============================================================================
export {
LLMCaller as SkillLLMCaller,
createLLMCaller,
getLLMCaller,
createOrchestratorLLMCaller,
type LLMCallerConfig,
type LLMCallOptions,
type LLMResponse,
} from "./llm/caller.js";
// ============================================================================
// Legacy Enhanced Loop (backward compatibility)
// ============================================================================
export {
EnhancedAgentLoop,
createEnhancedLoop,
DEFAULT_CONFIG,
} from "./enhanced-loop.js";
// ============================================================================
// State Management
// ============================================================================
export {
PlanStateManager,
getStateManager,
resetStateManager,
type PlanState,
type Checkpoint,
type StateManagerConfig,
} from "./state/persistence.js";
export {
StepTracker,
createStepTracker,
type StepTrackerConfig,
type CompletionAnalysis,
} from "./state/step-tracker.js";
export {
CheckpointManager,
getCheckpointManager,
resetCheckpointManager,
type CheckpointData,
type CheckpointConfig,
type RestoreResult,
} from "./state/checkpoint.js";
// ============================================================================
// Execution
// ============================================================================
export {
ApprovalGate,
getApprovalGate,
resetApprovalGate,
classifyToolRisk,
withApprovalGate,
type ApprovalGateConfig,
type ApprovalRequest,
type ApprovalResult,
type RiskLevel,
type ApprovalDecision,
} from "./execution/approval-gate.js";
export {
RetryEngine,
createRetryEngine,
type RetryConfig,
type ErrorDiagnosis,
type AlternativeApproach,
type RetryAttempt,
type RetryResult,
type ErrorCategory,
} from "./execution/retry-engine.js";
// ============================================================================
// Context Management
// ============================================================================
export {
ContextSummarizer,
createContextSummarizer,
estimateTokens,
estimateMessageTokens,
estimateTotalTokens,
type SummarizerConfig,
type SummarizationResult,
type Message,
type ContextSummary,
} from "./context/summarizer.js";
// Legacy exports from context/manager
export {
createTokenBudget,
createWorkingMemory,
shouldManageContext,
manageContext,
buildWorkingMemoryContext,
} from "./context/manager.js";
// ============================================================================
// Planning
// ============================================================================
export {
shouldGeneratePlan,
generatePlan,
reflect,
replan,
completeStep,
failStep,
getNextStep,
formatPlanForContext,
} from "./planning/planner.js";
// ============================================================================
// Tasks
// ============================================================================
export {
createTaskStack,
createTask,
findTask,
flattenTasks,
updateTaskStatus,
hasPendingDependencies,
getNextTask,
getActiveTask,
setActiveTask,
handleInterruption,
buildTaskContextPrompt,
serializeTaskStack,
restoreTaskStack,
calculateProgress,
getTaskStats,
} from "./tasks/task-stack.js";
// ============================================================================
// State Machine
// ============================================================================
export {
AgentStateMachine,
LoggingObserver,
MetricsObserver,
BroadcastObserver,
} from "./state-machine/fsm.js";
// ============================================================================
// Parallel Execution
// ============================================================================
export {
isReadOnlyTool,
hasSideEffects,
classifyToolDependencies,
executeToolCalls,
executeWithMetrics,
} from "./execution/parallel.js";
// ============================================================================
// Confidence Gates (legacy)
// ============================================================================
export {
classifyRisk,
isLowRisk,
assessConfidence,
quickAssessConfidence,
makeGateDecision,
gateAction,
createCheckpoint as createConfidenceCheckpoint,
resolveThresholds,
DEFAULT_THRESHOLDS,
} from "./execution/confidence-gate.js";
// ============================================================================
// Error Recovery (legacy)
// ============================================================================
export {
diagnoseAndRecover,
executeWithRecovery,
ErrorLearningStore,
} from "./execution/error-recovery.js";
// ============================================================================
// Types
// ============================================================================
export type {
TaskPlan,
PlanStep,
TaskStack,
Task,
TaskStatus,
ReflectionResult,
ToolCall,
ToolResult,
LLMCaller,
PlanningConfig,
EnhancedLoopConfig,
EnhancedLoopState,
} from "./types.js";
// ============================================================================
// Version
// ============================================================================
export const VERSION = "0.2.0";
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |