|

Build a Modular Skill-Based Agent System for LLMs with Dynamic Tool Routing in Python

✅

In this tutorial, we construct a full skill-based agent system for giant language fashions and discover how modular capabilities will be structured like an working system for AI brokers. We outline reusable abilities, connect metadata and schemas to them, register them in a central registry, and allow dynamic orchestration by way of instrument calling and multi-step reasoning. As we transfer by way of the implementation, we present how an agent can choose the precise ability for a job, compose a number of abilities for extra superior workflows, hot-load new capabilities at runtime, and monitor every part by way of an observability dashboard.

import os
import sys
import json
import time
import getpass
from abc import ABC, abstractmethod
from dataclasses import dataclass, discipline
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Type


strive:
   from openai import OpenAI
   from wealthy.console import Console
   from wealthy.panel import Panel
   from wealthy.desk import Table
   from wealthy.tree import Tree
besides ImportError:
   print("Missing dependencies. Run:  pip set up openai pydantic wealthy")
   sys.exit(1)


def get_api_key() -> str:
   """Prompt for the OpenAI API key securely (enter hidden in terminal)."""
   key = os.environ.get("OPENAI_API_KEY", "").strip()
   if key:
       print("✅  Using OPENAI_API_KEY from surroundings.")
       return key
   print("n🔑  Enter your OpenAI API key (enter hidden):")
   key = getpass.getpass("   API Key: ").strip()
   if not key:
       print("❌  No API key supplied. Exiting.")
       sys.exit(1)
   os.environ["OPENAI_API_KEY"] = key
   return key


API_KEY = get_api_key()
consumer  = OpenAI(api_key=API_KEY)
console = Console()
MODEL   = "gpt-4o-mini"


class SkillCategory(Enum):
   DATA        = "information"
   REASONING   = "reasoning"
   GENERATION  = "era"
   SYSTEM      = "system"
   INTEGRATION = "integration"
   META        = "meta"


@dataclass
class SkillMetainformation:
   identify:            str
   description:     str
   class:        SkillCategory
   model:         str        = "1.0.0"
   writer:          str        = "system"
   tags:            List[str]  = discipline(default_factory=record)
   requires_skills: List[str]  = discipline(default_factory=record)
   output_type:     str        = "textual content"
   cost_estimate:   float      = 0.001
   created_at:      str        = discipline(default_factory=lambda: datetime.now().isoformat())


class Skill(ABC):
   """
   Abstract base for each agent functionality.
   Each Skill is: self-describing · versioned · testable · composable.
   """


   def __init__(self):
       self.metadata        = self._define_metadata()
       self.schema          = self._define_schema()
       self._call_count     = 0
       self._total_latency  = 0.0


   @abstractmethod
   def _define_metadata(self) -> SkillMetainformation: ...


   @abstractmethod
   def _define_schema(self) -> dict: ...


   @abstractmethod
   def execute(self, **kwargs) -> Any: ...


   def __call__(self, **kwargs) -> Any:
       t0     = time.time()
       consequence = self.execute(**kwargs)
       self._call_count    += 1
       self._total_latency += (time.time() - t0) * 1000
       return consequence


   def to_openai_tool(self) -> dict:
       return {
           "sort": "operate",
           "operate": {
               "identify":        self.metadata.identify,
               "description": self.metadata.description,
               "parameters":  self.schema,
           }
       }


   @property
   def stats(self) -> dict:
       avg = spherical(self._total_latency / self._call_count, 2) if self._call_count else 0
       return {"calls": self._call_count, "avg_latency_ms": avg}


class SkillRegistry:
   """
   Central catalog of all agent capabilities.
   Analogue: OS course of/syscall desk.
   """


   def __init__(self):
       self._skills:          Dict[str, Skill]       = {}
       self._category_index:  Dict[str, List[str]]   = {}
       self._tag_index:       Dict[str, List[str]]   = {}


   def register(self, ability: Skill) -> "SkillRegistry":
       identify = ability.metadata.identify
       self._skills[name] = ability
       self._category_index.setdefault(ability.metadata.class.worth, []).append(identify)
       for tag in ability.metadata.tags:
           self._tag_index.setdefault(tag, []).append(identify)
       return self


   def get(self, identify: str) -> Optional[Skill]:
       return self._skills.get(identify)


   def list_all(self) -> List[Skill]:
       return record(self._skills.values())


   def get_by_category(self, cat: SkillCategory) -> List[Skill]:
       return [self._skills[n] for n in self._category_index.get(cat.worth, [])]


   def to_openai_tools(self, names: Optional[List[str]] = None) -> List[dict]:
       abilities = ([self._skills[n] for n in names if n in self._skills]
                 if names else record(self._skills.values()))
       return [s.to_openai_tool() for s in skills]


   def show(self):
       tbl = Table(title="📚 Skill Registry", header_style="daring cyan", show_lines=True)
       tbl.add_column("Name",        model="daring")
       tbl.add_column("Category",    model="yellow")
       tbl.add_column("Version")
       tbl.add_column("Tags",        model="dim")
       tbl.add_column("Description")
       for s in self._skills.values():
           m = s.metadata
           tbl.add_row(m.identify, m.class.worth, m.model,
                       ", ".be a part of(m.tags[:3]),
                       m.description[:65] + ("…" if len(m.description) > 65 else ""))
       console.print(tbl)


   def __len__(self):
       return len(self._skills)

We arrange the core surroundings and initialize the system required to construct our skill-based agent framework. We outline basic abstractions corresponding to Skill, SkillMetainformation, and SkillCategory, which permit us to characterize every functionality as a structured, self-describing module. We additionally configure the OpenAI consumer, safe the API key enter, and set up the bottom structure that every one system abilities will inherit.

class CalculatorSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="calculator",
           description="Evaluate mathematical expressions. Supports arithmetic, powers, and "
                       "math features: sqrt, abs, spherical, log, sin, cos, tan.",
           class=SkillCategory.REASONING,
           tags=["math", "arithmetic", "compute"],
           output_type="textual content", cost_estimate=0.0,
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {"expression": {"sort": "string",
                   "description": "A Python math expression e.g. '2**10 + sqrt(144)'"}},
               "required": ["expression"]}


   def execute(self, expression: str) -> str:
       import math
       protected = {"__builtins__": {}, "sqrt": math.sqrt, "abs": abs, "spherical": spherical,
               "pow": pow, "log": math.log, "pi": math.pi, "e": math.e,
               "sin": math.sin, "cos": math.cos, "tan": math.tan}
       strive:
           return f"Result: {eval(expression, protected)}"
       besides Exception as ex:
           return f"Error: {ex}"


class TextSummarizerSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="text_summarizer",
           description="Summarize textual content at three verbosity ranges: temporary (1-2 sentences), "
                       "normal (1 paragraph), or detailed (structured bullets).",
           class=SkillCategory.GENERATION,
           tags=["summarize", "nlp", "text", "writing"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "textual content": {"sort": "string"},
                   "mode": {"sort": "string", "enum": ["brief", "standard", "detailed"],
                            "default": "normal"}},
               "required": ["text"]}


   def execute(self, textual content: str, mode: str = "normal") -> str:
       directions = {"temporary": "in 1-2 sentences", "normal": "in one paragraph",
                       "detailed": "as structured bullet factors protecting predominant concepts, key particulars, and conclusions"}
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=300,
           messages=[
               {"role": "system",  "content": f"Summarize {instructions.get(mode, instructions['standard'])}. Be concise."},
               {"function": "person",    "content material": textual content}])
       return r.decisions[0].message.content material


class DataAnalystSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="data_analyst",
           description="Analyse structured information (JSON or CSV) and extract statistical insights, "
                       "traits, or reply particular questions.",
           class=SkillCategory.DATA,
           tags=["data", "analysis", "statistics", "csv", "json"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "information":     {"sort": "string", "description": "Data as JSON array or CSV"},
                   "query": {"sort": "string", "description": "Analytical query to reply"}},
               "required": ["data", "question"]}


   def execute(self, information: str, query: str) -> str:
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=400,
           messages=[
               {"role": "user",   "content": f"Data:n{data}nnQuestion: {question}"}])
       return r.decisions[0].message.content material


class CodeGeneratorSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="code_generator",
           description="Generate clear, commented Python code for a given job with a temporary rationalization.",
           class=SkillCategory.GENERATION,
           tags=["code", "python", "programming", "script"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "job":     {"sort": "string"},
                   "language": {"sort": "string", "default": "python"}},
               "required": ["task"]}


   def execute(self, job: str, language: str = "python") -> str:
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=500,
           messages=[
               {"role": "system", "content": f"Expert {language} developer. Write clean, commented code with a one-line explanation."},
               {"role": "user",   "content": task}])
       return r.decisions[0].message.content material

We implement the SkillRegistry, which acts because the central catalog for all obtainable agent capabilities. We create mechanisms to register, retrieve, categorize, and expose abilities as instruments that the language mannequin can name dynamically. We additionally introduce the primary concrete ability implementations such because the calculator and summarizer, demonstrating how actual capabilities prolong the summary ability interface.

class FactCheckerSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="fact_checker",
           description="Assess the factual accuracy of a declare. Returns verdict, confidence rating, and rationalization.",
           class=SkillCategory.REASONING,
           tags=["fact", "verify", "truth", "accuracy"],
           output_type="json",
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {"declare": {"sort": "string"}},
               "required": ["claim"]}


   def execute(self, declare: str) -> str:
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=250,
           messages=[
               {"role": "system", "content": 'Fact checker. Respond ONLY with JSON: false'},
               {"role": "user",   "content": f"Fact-check: {claim}"}])
       return r.decisions[0].message.content material


class TranslationSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="translator",
           description="Translate textual content into any goal language with non-obligatory formality management.",
           class=SkillCategory.GENERATION,
           tags=["translate", "language", "multilingual"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "textual content":            {"sort": "string"},
                   "target_language": {"sort": "string"},
                   "formality":       {"sort": "string", "enum": ["formal", "informal"], "default": "formal"}},
               "required": ["text", "target_language"]}


   def execute(self, textual content: str, target_language: str, formality: str = "formal") -> str:
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=300,
           messages=[
               {"role": "system", "content": f"Translate to {target_language} ({formality}). Output only the translation."},
               {"role": "user",   "content": text}])
       return r.decisions[0].message.content material


class SentimentAnalyzerSkill(Skill):
   def _define_metadata(self):
       return SkillMetainformation(
           identify="sentiment_analyzer",
           description="Classify sentiment of textual content: polarity, depth, and confidence rating.",
           class=SkillCategory.REASONING,
           model="2.0.0",
           tags=["sentiment", "emotion", "nlp", "classification"],
           output_type="json",
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "textual content":     {"sort": "string"},
                   "detailed": {"sort": "boolean", "default": False}},
               "required": ["text"]}


   def execute(self, textual content: str, detailed: bool = False) -> str:
       additional = ' Also add "feelings":{"pleasure":0-1,"anger":0-1,"concern":0-1,"unhappiness":0-1}' if detailed else ""
       r = consumer.chat.completions.create(
           mannequin=MODEL, max_tokens=200,
           messages=[
               {"role": "system", "content": f'Respond ONLY with JSON: {neutral","intensity":0.0-1.0,"confidence":0.0-1.0}.{extra}'},
               {"role": "user",   "content": text}])
       return r.decisions[0].message.content material


class SkillIntrospectorSkill(Skill):
   """Meta-skill — brokers can question their very own functionality registry."""


   def __init__(self, registry: SkillRegistry):
       self._registry = registry
       tremendous().__init__()


   def _define_metadata(self):
       return SkillMetainformation(
           identify="skill_introspector",
           description="List all obtainable abilities or get particulars about a particular ability. "
                       "Use when uncertain which ability handles a job.",
           class=SkillCategory.META,
           tags=["meta", "help", "discover", "list"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "motion":     {"sort": "string", "enum": ["list", "describe"]},
                   "skill_name": {"sort": "string"}},
               "required": ["action"]}


   def execute(self, motion: str, skill_name: str = None) -> str:
       if motion == "record":
           strains = ["Available skills:"]
           for s in self._registry.list_all():
               strains.append(f"  • {s.metadata.identify} [{s.metadata.category.value}]: {s.metadata.description[:80]}")
           return "n".be a part of(strains)
       if motion == "describe" and skill_name:
           s = self._registry.get(skill_name)
           if not s:
               return f"Skill '{skill_name}' not discovered."
           m = s.metadata
           return (f"Skill: {m.identify} v{m.model}nCategory: {m.class.worth}n"
                   f"Description: {m.description}nTags: {', '.be a part of(m.tags)}n"
                   f"Schema:n{json.dumps(s.schema, indent=2)}")
       return "Invalid motion."

We develop the system by including extra specialised abilities that allow reasoning and pure language processing duties. We implement instruments for information evaluation, code era, translation, sentiment evaluation, and reality checking, enabling the agent to unravel a broader vary of issues. We additionally add the SkillIntrospector, which allows the agent to examine its personal talents and uncover obtainable abilities.

class ResearchReportSkill(Skill):
   """
   Composite ability — orchestrates TextSummarizer + DataAnalyst + CodeGenerator.
   Demonstrates fractal ability structure from the analysis paper.
   """


   def __init__(self, registry: SkillRegistry):
       self._registry = registry
       tremendous().__init__()


   def _define_metadata(self):
       return SkillMetainformation(
           identify="research_report",
           description="Generate a structured analysis report by composing summarization, "
                       "information evaluation, and code era sub-skills.",
           class=SkillCategory.META,
           tags=["research", "report", "composite", "writing"],
           requires_skills=["text_summarizer", "data_analyst", "code_generator"],
       )


   def _define_schema(self):
       return {"sort": "object",
               "properties": {
                   "subject":        {"sort": "string"},
                   "information":         {"sort": "string"},
                   "include_code": {"sort": "boolean", "default": True}},
               "required": ["topic", "data"]}


   def execute(self, subject: str, information: str, include_code: bool = True) -> str:
       components = [f"# Research Report: {topic}n"]


       console.print("  [dim]→ Composite → text_summarizer[/dim]")
       abstract = self._registry.get("text_summarizer")(textual content=information, mode="detailed")
       components.append(f"## Summaryn{abstract}n")


       console.print("  [dim]→ Composite → data_analyst[/dim]")
       evaluation = self._registry.get("data_analyst")(
           information=information, query=f"Key quantitative insights about {subject}?")
       components.append(f"## Quantitative Analysisn{evaluation}n")


       if include_code:
           console.print("  [dim]→ Composite → code_generator[/dim]")
           code = self._registry.get("code_generator")(
               job=f"Python operate to course of and visualize information about {subject}")
           components.append(f"## Code Samplen{code}n")


       components.append(f"## Metadatan- Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}n"
                    f"- Skills used: text_summarizer, data_analyst"
                    + (", code_generator" if include_code else ""))
       return "n".be a part of(components)


class SkillLoader:
   """Package-manager analogue for the Agent OS."""


   def __init__(self, registry: SkillRegistry):
       self.registry = registry


   def load(self, skill_class: Type[Skill], *args, **kwargs) -> str:
       occasion = skill_class(*args, **kwargs)
       self.registry.register(occasion)
       console.print(f"[green]📦  Hot-loaded ability: {occasion.metadata.identify}[/green]")
       return occasion.metadata.identify


   def unload(self, identify: str) -> bool:
       if identify in self.registry._skills:
           del self.registry._skills[name]
           console.print(f"[yellow]🗑   Unloaded ability: {identify}[/yellow]")
           return True
       return False


class SkillBasedAgent:
   """
   LLM-driven agent that selects and chains abilities dynamically.


   Architecture:
       User Request
           ↓
       LLM Reasoning  ──→  tool_call
           ↓
       Skill Registry lookup
           ↓
       Skill Execution Engine
           ↓
       LLM Response Synthesis
           ↓
       Final Answer
   """


   def __init__(self, registry: SkillRegistry, identify: str = "AgentOS",
                max_iterations: int = 6, verbose: bool = True):
       self.registry       = registry
       self.identify           = identify
       self.max_iterations = max_iterations
       self.verbose        = verbose
       self.system_prompt  = (
           f"You are {identify}, an AI agent with a dynamic ability registry.nn"
           "PRINCIPLES:n"
           "1. Use probably the most acceptable ability for every sub-task.n"
           "2. Chain a number of abilities sequentially for complicated requests.n"
           "3. Use skill_introspector if uncertain which ability to choose.n"
           "4. Synthesize all ability outputs into a coherent closing reply.nn"
           f"Loaded abilities: {[s.metadata.name for s in registry.list_all()]}"
       )


   def _log(self, msg, **kw):
       if self.verbose:
           console.print(msg, **kw)


   def _dispatch(self, identify: str, args: dict) -> str:
       ability = self.registry.get(identify)
       if not ability:
           return f"Error: ability '{identify}' not in registry."
       self._log(f"  ⚡ [bold cyan]{identify}[/bold cyan]  args={json.dumps(args)[:120]}", model="")
       strive:
           consequence = ability(**args)
           self._log(f"     [green]{str(consequence)[:160]}[/green]")
           return str(consequence)
       besides Exception as ex:
           msg = f"Execution error: {ex}"
           self._log(f"     [red]{msg}[/red]")
           return msg


   def run(self, user_input: str) -> str:
       self._log(Panel(f"[bold]User:[/bold] {user_input}",
                       title=f"🤖  {self.identify}", border_style="blue"))


       messages = [
           {"role": "system", "content": self.system_prompt},
           {"role": "user",   "content": user_input},
       ]
       instruments = self.registry.to_openai_tools()


       for i in vary(self.max_iterations):
           self._log(f"n[dim]── iteration {i+1} ──[/dim]")


           resp   = consumer.chat.completions.create(
               mannequin=MODEL, messages=messages, instruments=instruments,
               tool_choice="auto", max_tokens=700)
           msg    = resp.decisions[0].message
           purpose = resp.decisions[0].finish_reason


           assistant_msg: dict = {"function": "assistant", "content material": msg.content material}
           if msg.tool_calls:
               assistant_msg["tool_calls"] = [tc.model_dump() for tc in msg.tool_calls]
           messages.append(assistant_msg)


           if purpose == "cease" or not msg.tool_calls:
               reply = msg.content material or "(no response)"
               self._log(Panel(f"[bold green]{reply}[/bold green]",
                               title="✅  Final Answer", border_style="inexperienced"))
               return reply


           for tc in msg.tool_calls:
               consequence = self._dispatch(tc.operate.identify,
                                       json.masses(tc.operate.arguments))
               messages.append({"function": "instrument",
                                 "tool_call_id": tc.id,
                                 "content material": consequence})


       return "Max iterations reached."

We show superior ideas, together with ability composition and runtime extensibility. We create a composite ResearchReportSkill that orchestrates a number of underlying abilities to mechanically produce a structured analysis report. We additionally implement the SkillLoader and the SkillBasedAgent, which collectively allow dynamic ability loading, instrument choice, and multi-step reasoning by way of the LLM-driven execution loop.

def show_dashboard(registry: SkillRegistry):
   console.print("n")
   console.print(Panel("[bold]Agent OS — Observability Dashboard[/bold]", border_style="blue"))


   tree = Tree("🌳 [bold]Skill Tree[/bold]")
   for cat in SkillCategory:
       abilities = registry.get_by_category(cat)
       if abilities:
           department = tree.add(f"[yellow]{cat.worth.higher()}[/yellow]  ({len(abilities)})")
           for s in abilities:
               st = s.stats
               department.add(f"[cyan]{s.metadata.identify}[/cyan] v{s.metadata.model} | "
                          f"calls={st['calls']} | avg={st['avg_latency_ms']} ms")
   console.print(tree)


   tbl = Table(title="📈 Performance", header_style="daring magenta", show_lines=True)
   tbl.add_column("Skill",           model="daring")
   tbl.add_column("Calls",           justify="proper")
   tbl.add_column("Avg Latency ms",  justify="proper")
   tbl.add_column("Output Type")
   tbl.add_column("Deps")


   for s in sorted(registry.list_all(), key=lambda x: x._call_count, reverse=True):
       st  = s.stats
       col = "inexperienced" if st["avg_latency_ms"] < 1000 else ("yellow" if st["avg_latency_ms"] < 3000 else "crimson")
       tbl.add_row(s.metadata.identify, str(st["calls"]),
                   f"[{col}]{st['avg_latency_ms']}[/{col}]",
                   s.metadata.output_type,
                   ", ".be a part of(s.metadata.requires_skills) or "—")
   console.print(tbl)


   whole = sum(s._call_count for s in registry.list_all())
   used  = sum(1 for s in registry.list_all() if s._call_count > 0)
   console.print(f"n[bold]Summary:[/bold] {len(registry)} registered | {used} used | {whole} whole callsn")


def predominant():
   console.rule("[bold magenta]Skill-Based Agent Systems Tutorial[/bold magenta]")


   registry = SkillRegistry()
   loader   = SkillLoader(registry)


   (registry
       .register(CalculatorSkill())
       .register(TextSummarizerSkill())
       .register(DataAnalystSkill())
       .register(CodeGeneratorSkill())
       .register(FactCheckerSkill())
       .register(TranslationSkill())
       .register(SkillIntrospectorSkill(registry))
       .register(ResearchReportSkill(registry)))


   registry.show()


   agent = SkillBasedAgent(registry, identify="AgentOS-Alpha", verbose=True)


   console.rule("[bold yellow]DEMO 1 — Calculator Skill[/bold yellow]")
   agent.run("What is (2**16 + sqrt(1764)) * 0.5?")


   console.rule("[bold yellow]DEMO 2 — Text Summarizer Skill[/bold yellow]")
   textual content = (
       "The transformer structure, launched in 'Attention Is All You Need' (2017), "
       "revolutionised NLP by changing RNNs with parallel self-attention. Every token attends "
       "to each different token, capturing long-range dependencies effectively. Multi-head consideration "
       "learns numerous relationship sorts concurrently. Positional encodings inject order "
       "data. The encoder-decoder design underpins BERT, GPT-3, GPT-4, and all fashionable LLMs."
   )
   agent.run(f"Give me a temporary abstract: {textual content}")


   console.rule("[bold yellow]DEMO 3 — Fact Checker Skill[/bold yellow]")


   console.rule("[bold yellow]DEMO 4 — Multi-Skill Chain (Data + Calculator)[/bold yellow]")
   gross sales = json.dumps([
       {"month": "Jan", "revenue": 12500}, {"month": "Feb", "revenue": 14200},
       {"month": "Mar", "revenue": 11800}, {"month": "Apr", "revenue": 18900},
       {"month": "May", "revenue": 22100}, {"month": "Jun", "revenue": 19300},
   ])
   agent.run(
       f"Analyse this gross sales information: {gross sales}. "
       "Find whole income, greatest/worst months, and common month-to-month income. "
       "Then calculate: projected income if June grows 15%."
   )


   console.rule("[bold yellow]DEMO 5 — Code Generator Skill[/bold yellow]")
   agent.run(
       "Generate a Python operate that implements binary search on a sorted record, "
       "then translate the operate's docstring into Spanish."
   )


   console.rule("[bold yellow]DEMO 6 — Hot-Swap Skill Loading[/bold yellow]")
   loader.load(SentimentAnalyzerSkill)
   agent.system_prompt += f"nAdditionally loaded: sentiment_analyzer"
   agent.run(
       "Analyse the sentiment of: 'This product utterly exceeded my expectations! "
       "Absolutely excellent high quality and the assist staff was extremely responsive.'"
   )


   console.rule("[bold yellow]DEMO 7 — Composite Research Report Skill[/bold yellow]")
   ml_data = (
       "LLM Benchmarks 2025:n"
       "GPT-4o: MMLU 88.7%, HumanEval 90.2%, $5/1M tokensn"
       "Claude 3 Opus: MMLU 86.8%, HumanEval 84.9%, $15/1M tokensn"
       "Gemini 1.5 Pro: MMLU 85.9%, HumanEval 71.9%, $3.5/1M tokensn"
       "Llama 3.1 70B: MMLU 83.6%, HumanEval 80.5%, $0.72/1M tokensn"
   )
   report_skill = registry.get("research_report")
   report = report_skill(subject="LLM Model Performance Comparison", information=ml_data, include_code=True)
   console.print(Panel(report, title="📄 Research Report", border_style="cyan"))


   console.rule("[bold yellow]DEMO 8 — Full Agent OS Pipeline[/bold yellow]")
   agent.run(
       "1. Fact-check: 'Python was created by Linus Torvalds in 1989'.n"
       "2. Calculate month-to-month value: 1.5M tokens/day at $0.002 per 1000 tokens (30 days).n"
       "3. Summarise your findings in one temporary sentence."
   )


   show_dashboard(registry)


   console.print(Panel(
       "[bold green]Tutorial full![/bold green]n"
       "Key ideas demonstrated:n"
       "  • Skill abstraction & self-describing metadatan"
       "  • Skill Registry as Agent OS kerneln"
       "  • MCP-compatible instrument protocol (OpenAI operate calling)n"
       "  • Dynamic ability routing by way of LLM ReAct loopn"
       "  • Skill composition (fractal structure)n"
       "  • Hot-swap runtime loadingn"
       "  • Observability dashboard",
       title="🎓 Summary", border_style="magenta"
   ))


if __name__ == "__main__":
   predominant()

We construct the observability layer and the execution pipeline that demonstrates the system in motion. We assemble a dashboard to observe ability utilization, latency, and dependencies to grasp how the agent operates internally. Finally, we assemble the registry, load all abilities, run a number of demos, and execute a full multi-step agent workflow to showcase the whole skill-based structure.

In conclusion, we created a totally working skill-based agent framework that demonstrates how giant language mannequin brokers can grow to be extra modular, extensible, and interpretable. We confirmed how particular person abilities can operate as self-contained constructing blocks, how a registry can handle and expose these capabilities, and the way an agent can purpose over them to unravel easy and composite duties. Through runtime ability loading, chained execution, and monitoring of utilization statistics, we introduced a sensible structure that helps us consider agent programs not as a single monolithic mannequin however as an evolving ecosystem of specialised, composable intelligence.


Check out the Codes with Notebook here and Paper. Also, be at liberty to observe us on Twitter and don’t neglect to hitch our 130k+ ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.

Need to companion with us for selling your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar and so forth.? Connect with us

The publish Build a Modular Skill-Based Agent System for LLMs with Dynamic Tool Routing in Python appeared first on MarkTechPost.

Similar Posts