How sourabhvamdevan/ai-based-task-orchestration-project works
1. This repository is a Python 3.11 AI task-orchestration system centered on “Alfred,” a multi-agent environment that prioritizes personal/wellness tasks over work tasks. The architecture is split into an interactive orchestration layer, a custom RL environment, tool integrations, and training/inference paths.
2. The main runtime entrypoint is app.py, which README indicates launches a Gradio-based dashboard for interacting with the orchestrator. inference.py is the separate execution path for running a trained policy against the baseline, while the training workflow lives in training_process/alfred_grpo_colab2.ipynb.
3. The core control plane is agents/orchestrator.py. It acts as the routing layer that classifies incoming tasks by priority tier and dispatches them to specialized sub-agents. This is the key boundary where task intent becomes agent-specific execution.
4. The specialized agent layer is organized by responsibility:
- agents/auto_reply_agent.py for automated responses,
- agents/email_agent.py for Gmail-related actions,
- agents/habit_agent.py for recurring reminders and routines,
- agents/knowledge_agent.py for preference and knowledge-base handling.
These agents are downstream of the orchestrator and encapsulate domain-specific behavior.
5. External side effects are isolated behind the tools/ package. tools/gmail_tool.py, tools/calendar_tool.py, and tools/reminder_tool.py wrap integrations for email, scheduling, and reminders. tools/llm_client.py appears to be the shared LLM access layer, while tools/alfred-tool.py likely exposes a generic MCP-style tool interface used by the agents.
6. Authentication and API access are separated into auth/alfred_auth.py, which is the boundary for credentials and authorization against external services. The README also indicates Google Calendar and Gmail credentials are configured via environment variables, so the system depends on authenticated third-party API calls for real actions.
7. The RL environment is implemented under env/ with env/action_space.py and env/observation.py. This is where task queues are represented as model observations and the allowed actions are defined for the policy being trained.
8. Reward shaping is isolated in reward/rubric.py. This module encodes the project’s priority policy: Tier 1 tasks must outrank Tier 2 tasks, routing must be correct, required parameters must be complete, tool calls must succeed, and non-actionable tasks must not trigger actions. That reward boundary is what turns orchestration quality into a training signal.
9. Synthetic training data is generated in data/synthetic_todos.py, which suggests the environment is fed with simulated task episodes rather than only live user data. This supports policy learning and evaluation without needing real inbox/calendar traffic for every episode.
10. The project includes reproducibility and deployment scaffolding: requirements.txt for Python dependencies, Dockerfile for containerization, Jenkinsfile for CI/CD, and openenv.yaml for environment configuration. These files define how the system is packaged, tested, and run across environments.
11. The notebook checkpoints and training_process/ directory show that experimentation and policy optimization are notebook-driven, with GRPO/Unsloth/TRL mentioned in the README. In diagram terms, the training loop is separate from the interactive orchestrator: observations come from the environment, the policy is optimized against the rubric, and the resulting model is later exercised through inference.
12. A good architecture diagram for this repo should therefore show four main layers: input/UI and training entrypoints; orchestration and agent routing; tool/auth integrations to external services; and the RL environment/reward loop that shapes behavior. The critical data flow is task queue → observation → orchestrator/agent selection → tool call or abstention → reward feedback → policy update.
Main entry points: orchestrator.py Orchestrator · alfred-tool.py Alfred Tool · habit_agent.py Habit Agent · gmail_tool.py Gmail Tool
Components 18
Entrypoints
User-facing runtime and training entry paths
- App · Gradio-based interactive dashboard for task orchestration
app.py - Inference · Runs a trained policy against the baseline or environment
inference.py - Training Notebook · Notebook-driven policy optimization workflow
training_process/alfred_grpo_colab2.ipynb
Orchestration
Task routing and specialized agent execution
- Orchestrator · Classifies tasks by priority tier and dispatches them to agents
agents/orchestrator.py - Auto Reply · Handles automated response generation and reply tasks
agents/auto_reply_agent.py - Email Agent · Performs Gmail-related task execution
agents/email_agent.py - Habit Agent · Manages reminders, recurring routines, and habit tasks
agents/habit_agent.py - Knowledge Agent · Maintains preference and knowledge-base state
agents/knowledge_agent.py
Integrations
Tooling and external service boundaries
- LLM Client · Shared access layer for LLM calls
tools/llm_client.py - Gmail Tool · Wraps Gmail API operations
tools/gmail_tool.py - Calendar Tool · Wraps calendar operations and scheduling actions
tools/calendar_tool.py - Reminder Tool · Wraps reminder and recurring notification actions
tools/reminder_tool.py - Alfred Tool · Generic MCP-style tool interface used by agents
tools/alfred-tool.py - Auth · Handles authorization and external service credentials
auth/alfred_auth.py
RL Loop
Environment, reward, and synthetic training data
- Action Space · Defines allowed actions for the policy
env/action_space.py - Observation · Represents task queues as environment observations
env/observation.py - Rubric · Encodes task priority and execution quality into reward signals
reward/rubric.py - Synthetic Todos · Generates synthetic task episodes for training and evaluation
data/synthetic_todos.py
Connections 24
- App → Orchestrator: submit tasks · Interactive dashboard sends tasks into the routing core
- Inference → Orchestrator: run policy · Inference path exercises orchestration decisions
- Training Notebook → Synthetic Todos: generate episodes · Notebook uses synthetic tasks for policy optimization
- Training Notebook → Observation: build observations · Training consumes environment observations
- Synthetic Todos → Observation: seed tasks · Synthetic task episodes populate observations
- Observation → Orchestrator: state input · Observed queue state is routed through the orchestrator
- Orchestrator → Auto Reply: route tier · Dispatches tasks to the automated reply agent
- Orchestrator → Email Agent: route tier · Dispatches email tasks to the email agent
- Orchestrator → Habit Agent: route tier · Dispatches recurring routine tasks to the habit agent
- Orchestrator → Knowledge Agent: route tier · Dispatches preference and memory tasks to the knowledge agent
- Auto Reply → LLM Client: compose · Uses model access for response generation
- Email Agent → Gmail Tool: send/read · Calls Gmail operations through the tool wrapper
- Habit Agent → Reminder Tool: schedule · Uses reminder actions for routines and follow-ups
- Habit Agent → Calendar Tool: plan · Uses calendar actions for recurring scheduling
- Knowledge Agent → LLM Client: update memory · Uses the LLM layer to interpret and store preference knowledge
- Gmail Tool → Auth: authorize · Requires authenticated access to Gmail services
- Calendar Tool → Auth: authorize · Requires authenticated access to calendar services
- Reminder Tool → Auth: authorize · Requires credentialed access for reminder delivery
- Alfred Tool → Gmail Tool: wraps · Generic tool interface can expose Gmail actions
- Alfred Tool → Calendar Tool: wraps · Generic tool interface can expose calendar actions
- Alfred Tool → Reminder Tool: wraps · Generic tool interface can expose reminder actions
- Orchestrator → Action Space: choose action · Routing decisions are constrained by the available action set
- Orchestrator → Rubric: trained against · Orchestration quality is scored by the reward rubric
- Rubric → Action Space: evaluate · Reward checks whether chosen actions are valid and complete