• bitcoinBitcoin(BTC)$83,914.00-0.06%
  • ethereumEthereum(ETH)$2,670.40-0.65%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$767.81-0.81%
  • rippleXRP(XRP)$1.51-3.81%
  • usd-coinUSDC(USDC)$1.00-0.01%
  • solanaSolana(SOL)$120.25-1.56%
  • tronTRON(TRX)$0.334847-0.85%
  • zcashZcash(ZEC)$1,566.071.36%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.02-0.30%
  • HyperliquidHyperliquid(HYPE)$91.32-0.46%
  • dogecoinDogecoin(DOGE)$0.095575-2.57%
  • chainlinkChainlink(LINK)$13.920.05%
  • moneroMonero(XMR)$547.81-2.05%
  • whitebitWhiteBIT Coin(WBT)$83.66-0.20%
  • USDSUSDS(USDS)$1.00-0.01%
  • cardanoCardano(ADA)$0.249099-2.43%
  • RainRain(RAIN)$0.0127794.66%
  • leo-tokenLEO Token(LEO)$8.961.51%
  • stellarStellar(XLM)$0.214097-2.39%
  • bitcoin-cashBitcoin Cash(BCH)$333.24-2.28%
  • nearNEAR Protocol(NEAR)$4.78-6.37%
  • uniswapUniswap(UNI)$9.45-2.04%
  • litecoinLitecoin(LTC)$71.05-0.34%
  • CantonCanton(CC)$0.1326902.74%
  • Ethena USDeEthena USDe(USDE)$1.00-0.02%
  • avalanche-2Avalanche(AVAX)$10.580.27%
  • suiSui(SUI)$1.14-3.15%
  • daiDai(DAI)$1.000.00%
  • USD1USD1(USD1)$1.000.00%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.568.17%
  • hedera-hashgraphHedera(HBAR)$0.092131-3.10%
  • BittensorBittensor(TAO)$313.260.42%
  • shiba-inuShiba Inu(SHIB)$0.000006-1.02%
  • Global DollarGlobal Dollar(USDG)$1.00-0.02%
  • crypto-com-chainCronos(CRO)$0.065019-0.95%
  • BitwayBitway(BTW)$1.04-20.10%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.02%
  • MemeCoreMemeCore(M)$1.211.41%
  • EthenaEthena(ENA)$0.2678271.43%
  • tether-goldTether Gold(XAUT)$4,279.44-0.18%
  • OndoOndo(ONDO)$0.53-2.58%
  • okbOKB(OKB)$120.11-0.41%
  • Ripple USDRipple USD(RLUSD)$1.000.00%
  • Circle USYCCircle USYC(USYC)$1.140.00%
  • aaveAave(AAVE)$153.340.36%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.15-0.12%
  • mantleMantle(MNT)$0.682.08%
  • polkadotPolkadot(DOT)$1.221.32%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

A Coding Guide to Design an Agentic AI System Using a Control-Plane Architecture for Safe, Modular, and Scalable Tool-Driven Reasoning Workflows

November 29, 2025
in AI & Technology
Reading Time: 8 mins read
A A
A Coding Guide to Design an Agentic AI System Using a Control-Plane Architecture for Safe, Modular, and Scalable Tool-Driven Reasoning Workflows
ShareShareShareShareShare

In this tutorial, we build an advanced Agentic AI using the control-plane design pattern, and we walk through each component step by step as we implement it. We treat the control plane as the central orchestrator that coordinates tools, manages safety rules, and structures the reasoning loop. Also, we set up a miniature retrieval system, defined modular tools, and integrated an agentic reasoning layer that dynamically plans and executes actions. At last, we observe how the entire system behaves like a disciplined, tool-aware AI capable of retrieving knowledge, assessing understanding, updating learner profiles, and logging all interactions through a unified, scalable architecture. Check out the FULL CODES here.

import subprocess
import sys


def install_deps():
   deps = ['anthropic', 'numpy', 'scikit-learn']
   for dep in deps:
       subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', dep])


try:
   import anthropic
except ImportError:
   install_deps()
   import anthropic


import json
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
from dataclasses import dataclass, asdict
from typing import List, Dict, Any, Optional
from datetime import datetime


@dataclass
class Document:
   id: str
   content: str
   metadata: Dict[str, Any]
   embedding: Optional[np.ndarray] = None


class SimpleRAGRetriever:
   def __init__(self):
       self.documents = self._init_knowledge_base()
  
   def _init_knowledge_base(self) -> List[Document]:
       docs = [
           Document("cs101", "Python basics: Variables store data. Use x=5 for integers, name="Alice" for strings. Print with print().", {"topic": "python", "level": "beginner"}),
           Document("cs102", "Functions encapsulate reusable code. Define with def func_name(params): and call with func_name(args).", {"topic": "python", "level": "intermediate"}),
           Document("cs103", "Object-oriented programming uses classes. class MyClass: defines structure, __init__ initializes instances.", {"topic": "python", "level": "advanced"}),
           Document("math101", "Linear algebra: Vectors are ordered lists of numbers. Matrix multiplication combines transformations.", {"topic": "math", "level": "intermediate"}),
           Document("ml101", "Machine learning trains models on data to make predictions. Supervised learning uses labeled examples.", {"topic": "ml", "level": "beginner"}),
           Document("ml102", "Neural networks are composed of layers. Each layer applies weights and activation functions to transform inputs.", {"topic": "ml", "level": "advanced"}),
       ]
       for i, doc in enumerate(docs):
           doc.embedding = np.random.rand(128)
           doc.embedding[i*20:(i+1)*20] += 2
       return docs
  
   def retrieve(self, query: str, top_k: int = 2) -> List[Document]:
       query_embedding = np.random.rand(128)
       scores = [cosine_similarity([query_embedding], [doc.embedding])[0][0] for doc in self.documents]
       top_indices = np.argsort(scores)[-top_k:][::-1]
       return [self.documents[i] for i in top_indices]

We set up all dependencies, import the libraries we rely on, and initialize the data structures for our knowledge base. We define a simple retriever and generate mock embeddings to simulate similarity search in a lightweight way. As we run this block, we prepare everything needed for retrieval-driven reasoning in the later components. Check out the FULL CODES here.

YOU MAY ALSO LIKE

You Can Use Your Old Laptop To Make A Smart Home Hub

TikTok Will Pay Alabama $100 Million To Settle Social Media Addiction Lawsuit

class ToolRegistry:
   def __init__(self, retriever: SimpleRAGRetriever):
       self.retriever = retriever
       self.interaction_log = []
       self.user_state = {"level": "beginner", "topics_covered": []}
  
   def search_knowledge(self, query: str, filters: Optional[Dict] = None) -> Dict:
       docs = self.retriever.retrieve(query, top_k=2)
       if filters:
           docs = [d for d in docs if all(d.metadata.get(k) == v for k, v in filters.items())]
       return {
           "tool": "search_knowledge",
           "results": [{"content": d.content, "metadata": d.metadata} for d in docs],
           "count": len(docs)
       }
  
   def assess_understanding(self, topic: str) -> Dict:
       questions = {
           "python": ["What keyword defines a function?", "How do you create a variable?"],
           "ml": ["What is supervised learning?", "Name two types of ML algorithms."],
           "math": ["What is a vector?", "Explain matrix multiplication."]
       }
       return {
           "tool": "assess_understanding",
           "topic": topic,
           "questions": questions.get(topic, ["General comprehension check."])
       }
  
   def update_learner_profile(self, topic: str, level: str) -> Dict:
       if topic not in self.user_state["topics_covered"]:
           self.user_state["topics_covered"].append(topic)
       self.user_state["level"] = level
       return {
           "tool": "update_learner_profile",
           "status": "updated",
           "profile": self.user_state.copy()
       }
  
   def log_interaction(self, event: str, details: Dict) -> Dict:
       log_entry = {
           "timestamp": datetime.now().isoformat(),
           "event": event,
           "details": details
       }
       self.interaction_log.append(log_entry)
       return {"tool": "log_interaction", "status": "logged", "entry_id": len(self.interaction_log)}

We build the tool registry that our agent uses while interacting with the system. We define tools such as knowledge search, assessments, profile updates, and logging, and we maintain a persistent user-state dictionary. As we use this layer, we see how each tool becomes a modular capability that the control plane can route to. Check out the FULL CODES here.

class ControlPlane:
   def __init__(self, tool_registry: ToolRegistry):
       self.tools = tool_registry
       self.safety_rules = {
           "max_tools_per_request": 4,
           "allowed_tools": ["search_knowledge", "assess_understanding",
                             "update_learner_profile", "log_interaction"]
       }
       self.execution_log = []
  
   def execute(self, plan: Dict[str, Any]) -> Dict[str, Any]:
       if not self._validate_request(plan):
           return {"error": "Safety validation failed", "plan": plan}
      
       action = plan.get("action")
       params = plan.get("parameters", {})
       result = self._route_and_execute(action, params)
      
       self.execution_log.append({
           "timestamp": datetime.now().isoformat(),
           "plan": plan,
           "result": result
       })
      
       return {
           "success": True,
           "action": action,
           "result": result,
           "metadata": {
               "execution_count": len(self.execution_log),
               "safety_checks_passed": True
           }
       }
  
   def _validate_request(self, plan: Dict) -> bool:
       action = plan.get("action")
       if action not in self.safety_rules["allowed_tools"]:
           return False
       if len(self.execution_log) >= 100:
           return False
       return True
  
   def _route_and_execute(self, action: str, params: Dict) -> Any:
       tool_map = {
           "search_knowledge": self.tools.search_knowledge,
           "assess_understanding": self.tools.assess_understanding,
           "update_learner_profile": self.tools.update_learner_profile,
           "log_interaction": self.tools.log_interaction
       }
       tool_func = tool_map.get(action)
       if tool_func:
           return tool_func(**params)
       return {"error": f"Unknown action: {action}"}

We implement the control plane that orchestrates tool execution, checks safety rules, and manages permissions. We validate every request, route actions to the right tool, and keep an execution log for transparency. As we run this snippet, we observe how the control plane becomes the governing system that ensures predictable and safe agentic behavior. Check out the FULL CODES here.

class TutorAgent:
   def __init__(self, control_plane: ControlPlane, api_key: str):
       self.control_plane = control_plane
       self.client = anthropic.Anthropic(api_key=api_key)
       self.conversation_history = []
  
   def teach(self, student_query: str) -> str:
       plan = self._plan_actions(student_query)
       results = []
       for action_plan in plan:
           result = self.control_plane.execute(action_plan)
           results.append(result)
      
       response = self._synthesize_response(student_query, results)
      
       self.conversation_history.append({
           "query": student_query,
           "plan": plan,
           "results": results,
           "response": response
       })
       return response
  
   def _plan_actions(self, query: str) -> List[Dict]:
       plan = []
       query_lower = query.lower()
      
       if any(kw in query_lower for kw in ["what", "how", "explain", "teach"]):
           plan.append({
               "action": "search_knowledge",
               "parameters": {"query": query},
               "context": {"intent": "knowledge_retrieval"}
           })
      
       if any(kw in query_lower for kw in ["test", "quiz", "assess", "check"]):
           topic = "python" if "python" in query_lower else "ml"
           plan.append({
               "action": "assess_understanding",
               "parameters": {"topic": topic},
               "context": {"intent": "assessment"}
           })
      
       plan.append({
           "action": "log_interaction",
           "parameters": {"event": "query_processed", "details": {"query": query}},
           "context": {"intent": "logging"}
       })
      
       return plan
  
   def _synthesize_response(self, query: str, results: List[Dict]) -> str:
       response_parts = [f"Student Query: {query}\n"]
      
       for result in results:
           if result.get("success") and "result" in result:
               tool_result = result["result"]
              
               if result["action"] == "search_knowledge":
                   response_parts.append("\n📚 Retrieved Knowledge:")
                   for doc in tool_result.get("results", []):
                       response_parts.append(f"  • {doc['content']}")
              
               elif result["action"] == "assess_understanding":
                   response_parts.append("\n✅ Assessment Questions:")
                   for q in tool_result.get("questions", []):
                       response_parts.append(f"  • {q}")
      
       return "\n".join(response_parts)

We implement the TutorAgent, which plans actions, communicates with the control plane, and synthesizes final responses. We analyze queries, generate multi-step plans, and combine tool outputs into meaningful answers for learners. As we execute this snippet, we see the agent behaving intelligently by coordinating retrieval, assessment, and logging. Check out the FULL CODES here.

def run_demo():
   print("=" * 70)
   print("Control Plane as a Tool: RAG AI Tutor Demo")
   print("=" * 70)
  
   API_KEY = "your-api-key-here"
  
   retriever = SimpleRAGRetriever()
   tool_registry = ToolRegistry(retriever)
   control_plane = ControlPlane(tool_registry)
  
   print("System initialized")
   print(f"Tools: {len(control_plane.safety_rules['allowed_tools'])}")
   print(f"Knowledge base: {len(retriever.documents)} documents")
  
   try:
       tutor = TutorAgent(control_plane, API_KEY)
   except:
       print("Mock mode enabled")
       tutor = None
  
   demo_queries = [
       "Explain Python functions to me",
       "I want to learn about machine learning",
       "Test my understanding of Python basics"
   ]
  
   for query in demo_queries:
       print("\n--- Query ---")
       if tutor:
           print(tutor.teach(query))
       else:
           plan = [
               {"action": "search_knowledge", "parameters": {"query": query}},
               {"action": "log_interaction", "parameters": {"event": "query", "details": {}}}
           ]
           print(query)
           for action in plan:
               result = control_plane.execute(action)
               print(f"{action['action']}: {result.get('success', False)}")
  
   print("Summary")
   print(f"Executions: {len(control_plane.execution_log)}")
   print(f"Logs: {len(tool_registry.interaction_log)}")
   print(f"Profile: {tool_registry.user_state}")


if __name__ == "__main__":
   run_demo()

We run a complete demo that initializes all components, processes sample student queries, and prints system state summaries. We watch the agent step through retrieval and logging while the control plane enforces rules and tracks execution history. As we finish this block, we get a clear picture of how the entire architecture works together in a realistic teaching loop.

In conclusion, we gain a clear understanding of how the control-plane pattern simplifies orchestration, strengthens safety, and creates a clean separation between reasoning and tool execution. We now see how a retrieval system, tool registry, and agentic planning layer come together to form a coherent AI tutor that responds intelligently to student queries. As we experiment with the demo, we observe how the system routes tasks, applies rules, and synthesizes useful insights from tool outputs, all while remaining modular and extensible.


Check out the FULL CODES here. Feel free to check out our GitHub Page for Tutorials, Codes and Notebooks. Also, feel free to follow us on Twitter and don’t forget to join our 100k+ ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.


Asif Razzaq is the CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is committed to harnessing the potential of Artificial Intelligence for social good. His most recent endeavor is the launch of an Artificial Intelligence Media Platform, Marktechpost, which stands out for its in-depth coverage of machine learning and deep learning news that is both technically sound and easily understandable by a wide audience. The platform boasts of over 2 million monthly views, illustrating its popularity among audiences.

🙌 Follow MARKTECHPOST: Add us as a preferred source on Google.

Credit: Source link

ShareTweetSendSharePin

Related Posts

You Can Use Your Old Laptop To Make A Smart Home Hub
AI & Technology

You Can Use Your Old Laptop To Make A Smart Home Hub

September 26, 2026
TikTok Will Pay Alabama 0 Million To Settle Social Media Addiction Lawsuit
AI & Technology

TikTok Will Pay Alabama $100 Million To Settle Social Media Addiction Lawsuit

September 26, 2026
This App Lets You Use An Apple Watch With An Android Phone
AI & Technology

This App Lets You Use An Apple Watch With An Android Phone

September 26, 2026
These Xbox Players Got GTA 6 For Free The Hard Way
AI & Technology

These Xbox Players Got GTA 6 For Free The Hard Way

September 26, 2026
Next Post
Flooding displaces thousands across Malaysia

Flooding displaces thousands across Malaysia

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Iran launches new missile attacks

Iran launches new missile attacks

September 19, 2026
Ukrainian President Volodymyr Zelenskyy gifted puppy

Ukrainian President Volodymyr Zelenskyy gifted puppy

September 22, 2026
Man shot by ICE says he was put in detention with bullet lodged near spine – The Washington Post

Man shot by ICE says he was put in detention with bullet lodged near spine – The Washington Post

September 22, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!