Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Morgan Stanley Applies US Financial institution Constitution for Crypto Custody

    February 28, 2026

    Playing cards Towards Humanity Firm Desires To Give "Your F**king Cash Again" Over Trump's Unlawful Tariffs

    February 28, 2026

    Environment Protection Department Vacancies in Punjab March 2026 Advertisement

    February 28, 2026
    Facebook X (Twitter) Instagram
    Saturday, February 28
    Trending
    • Morgan Stanley Applies US Financial institution Constitution for Crypto Custody
    • Playing cards Towards Humanity Firm Desires To Give "Your F**king Cash Again" Over Trump's Unlawful Tariffs
    • Environment Protection Department Vacancies in Punjab March 2026 Advertisement
    • Kelowna mayor does not ask for more RCMP funding during Victoria trip – Okanagan
    • England’s win over New Zealand revives Pakistan’s last-4 probabilities
    • Anthropic Hits Back After US Military Labels It a ‘Supply Chain Risk’
    • Rolls-Royce warns UltraFan engine manufacturing might transfer abroad with out UK authorities funding
    • How to Create a Great Body, Second Edition
    • Vogue business’s darker aspect emerges throughout Milan Vogue Week
    • The 2.4 Million Ethereum Anchor: How Binance’s Illiquid Supply Is Absorbing ETH’s February Volatility
    Facebook X (Twitter) Instagram Pinterest Vimeo
    The News92The News92
    • Home
    • World
    • National
    • Sports
    • Crypto
    • Travel
    • Lifestyle
    • Jobs
    • Insurance
    • Gaming
    • AI & Tech
    • Health & Fitness
    The News92The News92
    Home - AI & Tech - A Coding Implementation to Construct a Hierarchical Planner AI Agent Utilizing Open-Supply LLMs with Instrument Execution and Structured Multi-Agent Reasoning
    AI & Tech

    A Coding Implementation to Construct a Hierarchical Planner AI Agent Utilizing Open-Supply LLMs with Instrument Execution and Structured Multi-Agent Reasoning

    Naveed AhmadBy Naveed AhmadFebruary 28, 2026Updated:February 28, 2026No Comments2 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    A Coding Implementation to Construct a Hierarchical Planner AI Agent Utilizing Open-Supply LLMs with Instrument Execution and Structured Multi-Agent Reasoning
    Share
    Facebook Twitter LinkedIn Pinterest Email


    def executor_agent(step: Dict[str, Any], context: Dict[str, Any]) -> StepResult:
       step_id = int(step.get("id", 0))
       title = step.get("title", f"Step {step_id}")
       software = step.get("software", "llm")
    
    
       ctx_compact = {
           "objective": context.get("objective"),
           "assumptions": context.get("assumptions", []),
           "prior_results": [
               {"step_id": r.step_id, "title": r.title, "tool": r.tool, "output": r.output[:1500]}
               for r in context.get("outcomes", [])
           ],
       }
    
    
       if software == "python":
           code = llm_chat(
               EXECUTOR_SYSTEM,
               consumer=(
                   f"Step:n{json.dumps(step, indent=2)}nn"
                   f"Context:n{json.dumps(ctx_compact, indent=2)}nn"
                   f"Write Python code that completes the step. Output ONLY code."
               ),
               max_new_tokens=700,
               temperature=0.2,
           )
           py = run_python(code)
           out = []
           out.append("PYTHON_CODE:n" + code)
           out.append("nEXECUTION_OK: " + str(py["ok"]))
           if py["stdout"]:
               out.append("nSTDOUT:n" + py["stdout"])
           if py["error"]:
               out.append("nERROR:n" + py["error"])
           return StepResult(step_id=step_id, title=title, software=software, output="n".be part of(out))
    
    
       result_text = llm_chat(
           EXECUTOR_SYSTEM,
           consumer=(
               f"Step:n{json.dumps(step, indent=2)}nn"
               f"Context:n{json.dumps(ctx_compact, indent=2)}nn"
               f"Return the step consequence."
           ),
           max_new_tokens=700,
           temperature=0.3,
       )
       return StepResult(step_id=step_id, title=title, software=software, output=result_text)
    
    
    
    
    def aggregator_agent(activity: str, plan: Dict[str, Any], outcomes: Listing[StepResult]) -> str:
       payload = {
           "activity": activity,
           "plan": plan,
           "outcomes": [{"step_id": r.step_id, "title": r.title, "tool": r.tool, "output": r.output[:2500]} for r in outcomes],
       }
       return llm_chat(
           AGGREGATOR_SYSTEM,
           consumer=f"Mix every little thing into the ultimate reply.nnINPUT:n{json.dumps(payload, indent=2)}",
           max_new_tokens=900,
           temperature=0.2,
       )
    
    
    
    
    def run_hierarchical_agent(activity: str, verbose: bool = True) -> Dict[str, Any]:
       plan = planner_agent(activity)
    
    
       if verbose:
           print("n====================")
           print("PLAN (from Planner)")
           print("====================")
           print(json.dumps(plan, indent=2))
    
    
       context = {
           "objective": plan.get("objective", activity),
           "assumptions": plan.get("assumptions", []),
           "outcomes": [],
       }
    
    
       outcomes: Listing[StepResult] = []
       for step in plan.get("steps", []):
           res = executor_agent(step, context)
           outcomes.append(res)
           context["results"].append(res)
    
    
           if verbose:
               print("n--------------------")
               print(f"STEP {res.step_id}: {res.title}  [tool={res.tool}]")
               print("--------------------")
               print(res.output)
    
    
       remaining = aggregator_agent(activity, plan, outcomes)
       if verbose:
           print("n====================")
           print("FINAL (from Aggregator)")
           print("====================")
           print(remaining)
    
    
       return {"activity": activity, "plan": plan, "outcomes": outcomes, "remaining": remaining}
    
    
    
    
    demo_task = """
    Create a sensible guidelines to launch a small multi-agent system in Python for coordinating logistics:
    - One planner agent that decomposes duties
    - Two executor brokers (routing + stock)
    - A easy reminiscence retailer for previous choices
    Maintain it light-weight and runnable in Colab.
    """
    
    
    _ = run_hierarchical_agent(demo_task, verbose=True)
    
    
    print("nnType your individual activity (or press Enter to skip):")
    user_task = enter().strip()
    if user_task:
       _ = run_hierarchical_agent(user_task, verbose=True)



    Source link

    breaking down the specifics so "AI Agent" fits as the primary concept. The focus on creating a plan in a structured hierarchy means "Hierarchical Planning" becomes essential. From there the first step is to identify the central themes and technologies at play. The heart of it is developing an AI agent When categorizing content like this
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleIAG broadcasts €1.5bn share buyback after file earnings at British Airways proprietor
    Next Article Israeli strikes kill seven extra Palestinians throughout Gaza – World
    Naveed Ahmad
    • Website
    • Tumblr

    Related Posts

    AI & Tech

    Anthropic Hits Back After US Military Labels It a ‘Supply Chain Risk’

    February 28, 2026
    AI & Tech

    Pentagon strikes to designate Anthropic as a supply-chain danger

    February 28, 2026
    AI & Tech

    How to Build Interactive Geospatial Dashboards Using Folium with Heatmaps, Choropleths, Time Animation, Marker Clustering, and Advanced Interactive Plugins

    February 28, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Demo
    Top Posts

    How to Get a Bigger Penis – The Stem Cell Secret to Natural Penis Enlargement & A Quiz

    February 22, 20261 Views

    Oatly loses ‘milk’ branding battle in UK Supreme Courtroom

    February 12, 20261 Views

    Morgan Stanley Applies US Financial institution Constitution for Crypto Custody

    February 28, 20260 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews

    Subscribe to Updates

    Get the latest tech news from FooBar about tech, design and biz.

    Demo
    Most Popular

    How to Get a Bigger Penis – The Stem Cell Secret to Natural Penis Enlargement & A Quiz

    February 22, 20261 Views

    Oatly loses ‘milk’ branding battle in UK Supreme Courtroom

    February 12, 20261 Views

    Morgan Stanley Applies US Financial institution Constitution for Crypto Custody

    February 28, 20260 Views
    Our Picks

    Morgan Stanley Applies US Financial institution Constitution for Crypto Custody

    February 28, 2026

    Playing cards Towards Humanity Firm Desires To Give "Your F**king Cash Again" Over Trump's Unlawful Tariffs

    February 28, 2026

    Environment Protection Department Vacancies in Punjab March 2026 Advertisement

    February 28, 2026

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    Facebook X (Twitter) Instagram Pinterest
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    • Advertise
    • Disclaimer
    © 2026 TheNews92.com. All Rights Reserved. Unauthorized reproduction or redistribution of content is strictly prohibited.

    Type above and press Enter to search. Press Esc to cancel.