• bitcoinBitcoin(BTC)$80,691.00-1.07%
  • ethereumEthereum(ETH)$2,282.54-2.18%
  • tetherTether(USDT)$1.000.01%
  • binancecoinBNB(BNB)$667.64-0.14%
  • rippleXRP(XRP)$1.44-2.81%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$94.52-3.10%
  • tronTRON(TRX)$0.348658-0.54%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.040.73%
  • dogecoinDogecoin(DOGE)$0.110634-0.64%
  • whitebitWhiteBIT Coin(WBT)$59.21-1.25%
  • USDSUSDS(USDS)$1.00-0.01%
  • cardanoCardano(ADA)$0.271680-3.52%
  • zcashZcash(ZEC)$580.173.56%
  • HyperliquidHyperliquid(HYPE)$40.31-3.13%
  • leo-tokenLEO Token(LEO)$9.98-0.73%
  • bitcoin-cashBitcoin Cash(BCH)$439.73-2.07%
  • moneroMonero(XMR)$412.81-0.21%
  • chainlinkChainlink(LINK)$10.32-2.50%
  • the-open-networkToncoin(TON)$2.31-4.54%
  • CantonCanton(CC)$0.153407-6.32%
  • stellarStellar(XLM)$0.162376-3.49%
  • suiSui(SUI)$1.24-5.12%
  • litecoinLitecoin(LTC)$57.92-0.88%
  • USD1USD1(USD1)$1.000.05%
  • daiDai(DAI)$1.000.01%
  • MemeCoreMemeCore(M)$3.300.16%
  • avalanche-2Avalanche(AVAX)$9.87-2.77%
  • hedera-hashgraphHedera(HBAR)$0.093808-3.33%
  • Ethena USDeEthena USDe(USDE)$1.00-0.01%
  • shiba-inuShiba Inu(SHIB)$0.000006-2.27%
  • RainRain(RAIN)$0.007528-0.10%
  • Global DollarGlobal Dollar(USDG)$1.000.01%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.02%
  • crypto-com-chainCronos(CRO)$0.0783860.47%
  • Circle USYCCircle USYC(USYC)$1.120.00%
  • BittensorBittensor(TAO)$311.12-2.85%
  • tether-goldTether Gold(XAUT)$4,708.74-0.70%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • uniswapUniswap(UNI)$3.77-3.30%
  • polkadotPolkadot(DOT)$1.34-1.92%
  • pax-goldPAX Gold(PAXG)$4,710.51-0.68%
  • mantleMantle(MNT)$0.67-3.68%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.067675-0.06%
  • nearNEAR Protocol(NEAR)$1.635.66%
  • OndoOndo(ONDO)$0.396931-9.32%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.13-0.37%
  • Pi NetworkPi Network(PI)$0.1738981.39%
  • okbOKB(OKB)$85.52-1.61%
  • Falcon USDFalcon USD(USDF)$1.000.04%
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

Build a Hybrid-Memory Autonomous Agent with Modular Architecture and Tool Dispatch Using OpenAI

May 12, 2026
in AI & Technology
Reading Time: 3 mins read
A A
Build a Hybrid-Memory Autonomous Agent with Modular Architecture and Tool Dispatch Using OpenAI
ShareShareShareShareShare

YOU MAY ALSO LIKE

Arm Warns of Phone Market Weakness | Bloomberg Tech 5/7/2026

Autonomous Driving Showdown: Who Will Win the Self-Driving Race? | Bloomberg Tech: Europe 5/08/2026

class MemoryStoreTool(Tool):
   name = "memory_store"
   description = "Save an important fact or piece of information to long-term memory."


   def __init__(self, memory: MemoryBackend):
       self._mem = memory


   def run(self, text: str, category: str = "general") -> str:
       chunk_id = self._mem.store(text, {"category": category})
       return f"Stored as {chunk_id}."


   def schema(self) -> Dict:
       return {
           "type": "function",
           "function": {
               "name": self.name,
               "description": self.description,
               "parameters": {
                   "type": "object",
                   "properties": {
                       "text":     {"type": "string", "description": "The fact to remember."},
                       "category": {"type": "string", "description": "Category tag, e.g. 'user_pref', 'task', 'fact'."},
                   },
                   "required": ["text"],
               },
           },
       }




class MemorySearchTool(Tool):
   name = "memory_search"
   description = "Search long-term memory for information relevant to a query."


   def __init__(self, memory: MemoryBackend):
       self._mem = memory


   def run(self, query: str, top_k: int = 3) -> str:
       results = self._mem.search(query, top_k=top_k)
       if not results:
           return "No relevant memories found."
       lines = [f"[{r['id']}] (score={r['rrf_score']}) {r['text']}" for r in results]
       return "Relevant memories:\n" + "\n".join(lines)


   def schema(self) -> Dict:
       return {
           "type": "function",
           "function": {
               "name": self.name,
               "description": self.description,
               "parameters": {
                   "type": "object",
                   "properties": {
                       "query": {"type": "string", "description": "What to look for."},
                       "top_k": {"type": "integer", "description": "Max results (default 3)."},
                   },
                   "required": ["query"],
               },
           },
       }




class CalculatorTool(Tool):
   name = "calculator"
   description = "Evaluate a safe mathematical expression, e.g. '2 ** 10 + sqrt(144)'."


   def run(self, expression: str) -> str:
       allowed = {k: getattr(math, k) for k in dir(math) if not k.startswith("_")}
       allowed.update({"abs": abs, "round": round})
       try:
           result = eval(expression, {"__builtins__": {}}, allowed)
           return str(result)
       except Exception as exc:
           return f"Error: {exc}"


   def schema(self) -> Dict:
       return {
           "type": "function",
           "function": {
               "name": self.name,
               "description": self.description,
               "parameters": {
                   "type": "object",
                   "properties": {
                       "expression": {"type": "string", "description": "Math expression to evaluate."},
                   },
                   "required": ["expression"],
               },
           },
       }




class WebSnippetTool(Tool):
   name = "web_search"
   description = "Search the web for current information on a topic (simulated)."


   _KB = {
       "openai": "OpenAI is an AI safety company that develops the GPT family of models.",
       "rag": "Retrieval-Augmented Generation (RAG) combines a retrieval system with an LLM to ground answers in external documents.",
       "bm25": "BM25 (Best Match 25) is a probabilistic keyword ranking function used in search engines.",
   }


   def run(self, query: str) -> str:
       q = query.lower()
       for kw, snippet in self._KB.items():
           if kw in q:
               return f"Web snippet for '{query}': {snippet}"
       return f"No snippet found for '{query}'. (Mock tool — integrate a real search API here.)"


   def schema(self) -> Dict:
       return {
           "type": "function",
           "function": {
               "name": self.name,
               "description": self.description,
               "parameters": {
                   "type": "object",
                   "properties": {
                       "query": {"type": "string", "description": "Search query."},
                   },
                   "required": ["query"],
               },
           },
       }




@dataclass
class AgentPersona:
   name: str
   role: str
   traits: List[str]
   forbidden_phrases: List[str] = field(default_factory=list)
   goals: List[str] = field(default_factory=list)


   def compile_system_prompt(self, extra_context: str = "") -> str:
       lines = [
           f"You are {self.name}, {self.role}.",
           "",
           "## Core Traits",
           *[f"- {t}" for t in self.traits],
       ]
       if self.goals:
           lines += ["", "## Goals", *[f"- {g}" for g in self.goals]]
       if self.forbidden_phrases:
           lines += ["", "## Forbidden Phrases (never say these)", *[f"- \"{p}\"" for p in self.forbidden_phrases]]
       if extra_context:
           lines += ["", "## Live Context", extra_context]
       lines += [
           "",
           "## Behaviour",
           "- Always reason step-by-step before answering.",
           "- Use available tools proactively; never guess when you can look up.",
           "- After using memory_search, quote the retrieved ID in your answer.",
           "- Keep answers concise unless depth is explicitly requested.",
       ]
       return "\n".join(lines)




ARIA = AgentPersona(
   name="Aria",
   role="a precise, helpful research assistant with a hybrid memory system",
   traits=["Methodical", "Curious", "Transparent about uncertainty", "Concise"],
   goals=[
       "Remember and connect information across conversations",
       "Use tools whenever they can improve accuracy",
   ],
   forbidden_phrases=["I cannot", "As an AI language model"],
)


print("✅  Tools and AgentPersona ready.")

Credit: Source link

ShareTweetSendSharePin

Related Posts

Arm Warns of Phone Market Weakness | Bloomberg Tech 5/7/2026
AI & Technology

Arm Warns of Phone Market Weakness | Bloomberg Tech 5/7/2026

May 13, 2026
Autonomous Driving Showdown: Who Will Win the Self-Driving Race? | Bloomberg Tech: Europe 5/08/2026
AI & Technology

Autonomous Driving Showdown: Who Will Win the Self-Driving Race? | Bloomberg Tech: Europe 5/08/2026

May 12, 2026
Waymo vs Wayve: The Self-Driving Showdown Coming to London
AI & Technology

Waymo vs Wayve: The Self-Driving Showdown Coming to London

May 12, 2026
NASA’s Chief on the Odds Aliens Have Already Found Earth
AI & Technology

NASA’s Chief on the Odds Aliens Have Already Found Earth

May 12, 2026
Next Post
Why the ‘SpaceMob’ Is So Bullish on AST

Why the 'SpaceMob' Is So Bullish on AST

Leave a Reply Cancel reply

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

Search

No Result
View All Result
Astronomers Use The Webb Telescope To Improve Our Map Of The Cosmic Web

Astronomers Use The Webb Telescope To Improve Our Map Of The Cosmic Web

May 11, 2026
KCE: Not The Best Tactical Approach To Financial Exposures

KCE: Not The Best Tactical Approach To Financial Exposures

May 9, 2026
Arm CEO Sees AI Demand While Smartphone Business Slumps

Arm CEO Sees AI Demand While Smartphone Business Slumps

May 7, 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!