How harshbhanushali26/ai-agent-engine works
AI Agent Engine is a cost-conscious conversational agent that routes queries through cache, deterministic pattern matching, personal-context retrieval, and—when needed—a defensive LLM workflow. The main entry point coordinates cache and agent requests; the agent plans, validates, executes tools, recovers from failures, and generates a response. Other documented capabilities include web search, weather, text extraction, and usage quotas. Edges reflect the README, excerpts, and source-index references; several unsampled subsystems are represented at their documented directory paths.
Main entry points: agent.py Agent orchestrator · registry.py Tool registry · main.py Interactive CLI · router.py Pattern router
Components 27
Query entry
- Interactive CLI
main.py - Query cache
core/memory.py
Fast paths
- Pattern router
core/routing/router.py - Date matcher
core/routing/datetime_pattern.py - Math matcher
core/routing/math_pattern.py - Text matcher
core/routing/text_pattern.py
Agent workflow
- Agent orchestrator
core/agent.py - Plan generation
core/planner.py - Plan validation
core/planner_validator.py - Step execution
core/executor.py - Tool runner
app/runner.py - Failure classifier
core/failure_classifier.py - Plan recovery
core/replanner.py - Execution state
core/state.py - Response generation
core/responder.py
Tool capabilities
- Tool registry
tools/registry.py - Safe calculator
tools/math/calculate.py - Date-time tools
tools/time/datetime.py - Text operations
tools/text/text_transform.py - Search and weather
tools/web - Text extraction
tools/text/extract_text.py - Preference retrieval
tools/rag/knowledge_base.py
Usage and contracts
- Quota and cost tracking
tools/usage_tracker.py - Tool contracts
tools/schemas.py - Tool response format
tools/responses.py
Other components
- User
- LLM service
Connections 37
- User → Interactive CLI: submits query
- Interactive CLI → Query cache: checks cache
main.py - Interactive CLI → Pattern router: routes query
main.py - Interactive CLI → Agent orchestrator: sends cache miss
main.py - Interactive CLI → Quota and cost tracking: checks quota
main.py - Pattern router → Date matcher: checks dates
core/routing/router.py - Pattern router → Math matcher: checks math
core/routing/router.py - Pattern router → Text matcher: checks text
core/routing/router.py - Date matcher → Date-time tools: uses operations
core/routing/datetime_pattern.py - Math matcher → Safe calculator: evaluates expression
core/routing/math_pattern.py - Text matcher → Text operations: uses operations
core/routing/text_pattern.py - Agent orchestrator → Plan generation: requests plan
core/agent.py - Agent orchestrator → Plan validation: validates plan
core/agent.py - Agent orchestrator → Step execution: executes plan
core/agent.py - Agent orchestrator → Response generation: generates response
core/agent.py - Agent orchestrator → Failure classifier: classifies failure
core/agent.py - Agent orchestrator → Plan recovery: repairs plan
core/agent.py - Step execution → Tool runner: runs steps
core/executor.py - Step execution → Execution state: resolves dependencies
core/executor.py - Tool runner → Tool registry: dispatches tools
app/runner.py - Plan recovery → Plan generation: requests replacement plan
core/replanner.py - Plan recovery → Plan validation: validates replacement
core/replanner.py - Plan generation → LLM service: requests completion
core/planner.py - Response generation → LLM service: requests completion
core/responder.py - Tool registry → Safe calculator: registers handler
tools/registry.py - Tool registry → Date-time tools: registers handlers
tools/registry.py - Tool registry → Text operations: registers handler
tools/registry.py - Tool registry → Search and weather: registers handlers
tools/registry.py - Tool registry → Text extraction: registers handler
tools/registry.py - Tool registry → Preference retrieval: registers handler
tools/registry.py - Interactive CLI → Preference retrieval: retrieves context
- Agent orchestrator → Quota and cost tracking: tracks calls
core/agent.py - Plan generation → Tool contracts: uses contracts
core/planner.py - Plan validation → Tool registry: checks tool catalog
core/planner_validator.py - Safe calculator → Tool response format: formats result
tools/math/calculate.py - Date-time tools → Tool response format: formats result
tools/time/datetime.py - Response generation → Tool contracts: uses contracts
core/responder.py