{"id":1890,"date":"2024-01-22T07:59:41","date_gmt":"2024-01-22T15:59:41","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=1890"},"modified":"2024-02-05T18:13:15","modified_gmt":"2024-02-06T02:13:15","slug":"microagents-exploring-agentic-architecture-with-microservices","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/microagents-exploring-agentic-architecture-with-microservices\/","title":{"rendered":"MicroAgents: Exploring Agentic Architecture with Microservices"},"content":{"rendered":"<p>Throughout our time building Semantic Kernel and working with customers, <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/openai-assistants-the-power-of-templated-assistant-instructions\/\">we&#8217;ve introduced agents<\/a> and have just started to explore the potential of <em>autonomous<\/em> AI agents. While the community is in the midst of exploring various architectures for these agents, one source we can draw inspiration from is the microservice architecture.<\/p>\n<p>Consider the benefits of microservices:<\/p>\n<ul>\n<li>Ease of maintenance: feature enhancement &amp; validation<\/li>\n<li>Reliability: fault isolation &amp; diagnostics<\/li>\n<li>Efficiency: cost &amp; flexibility<\/li>\n<li>Deployment agility: frequency &amp; scaling<\/li>\n<\/ul>\n<p>In this post, we&#8217;ll cover what we&#8217;re calling <strong><span style=\"color: #cc99ff;\">MicroAgents <\/span><\/strong>and talk through what some of the benefits this approach could provide.\u00a0 Let&#8217;s dive in!<\/p>\n<h4>What is an Agent?<\/h4>\n<p>From the perspective of <a href=\"https:\/\/learn.microsoft.com\/en-us\/semantic-kernel\/overview\/\">Semantic Kernel<\/a> orchestration, an AI agent is a modular abstraction that can possess a persona, can perform actions in response to user input, and can easily communicate with other agents.<\/p>\n<p>You might also view an agent from an <em>AI-as-a-service<\/em> perspective or as an <em>autonomous worker<\/em>.<\/p>\n<p>The <em>MicroAgent<\/em>\u00a0pattern adapts to either perspective.<\/p>\n<h4>Microagents<\/h4>\n<p>Take the case of an AI personal assistant with various services: location, <span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">calendar, <\/span>email, <span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">banking, <\/span><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">shopping, <\/span><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">travel, <\/span><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">weather, e<\/span><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">tc&#8230;\u00a0 If you were to build this as a monolithic agent, it would be directly bound to its tooling. Namely, all provided functions and plugins would need to fit in that agent&#8217;s model context. <\/span><\/p>\n<p><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">In addition, the agent would have to decide which among possibly thousands of services to call, making it tedious to give the agent nuanced system instructions.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents.png\"><img decoding=\"async\" class=\"wp-image-1894 size-large aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-1024x483.png\" alt=\"Image monoagents\" width=\"640\" height=\"302\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-1024x483.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-300x142.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-768x362.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-1536x725.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/monoagents-2048x966.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Partitioning by functional domain and utilizing agent composition introduces a <em>MicroAgent <\/em>pattern which associates each microagent with a service. Each microagent&#8217;s system instructions can be tailored for factors specific to its service. Natural language interactions define a durable, elastic interface for combining and coordinating loosely coupled microagents to accomplish complex tasks.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1893 size-large\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-1024x639.png\" alt=\"Image microagents\" width=\"640\" height=\"399\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-1024x639.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-300x187.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-768x479.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-1536x958.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/01\/microagents-2048x1278.png 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>While this pattern may be intriguing, it certainly isn&#8217;t the only approach for defining AI agents and no single approach need be exclusive. For example, it&#8217;s easy to envision <em>persona<\/em>, <em>role<\/em>, or <em>task-<\/em>based agents existing alongside and utilizing <em>MicroAgents<\/em>.<\/p>\n<h4>Observations<\/h4>\n<p>We wanted to create a comparison between either approach for basic validation.<\/p>\n<p>For this experiment, eight critical APIs and twelve irrelevant APIs were defined across 5 microagents.\u00a0 Not the scale of hundreds or thousands of API&#8217;s you might find at production scale, but sufficient surface initial qualitative differences.<\/p>\n<p>The user message was to <em>book a four night vacation to Hawaii<\/em> with intentional ambiguity around current date, travel dates, home location, airport codes, and need for return flight.<\/p>\n<p>The first thing that stood out is just how amazing <code>gpt-4-turbo<\/code> is at coordinating complex function calling. As expected, completion rates drop-off on lesser models.<\/p>\n<p>Our experimental completion rates for either approach were effectively equivalent: 80% &#8211; 85%.\u00a0 Either approach would sometimes omit adding the trip to the calendar. The <em>monoagent<\/em> approach would sometimes fail to book a return trip and even once required additional confirmation before booking.<\/p>\n<p>The first step either approach took was to consult the calendar on which dates might be available to travel. Each approach reliably executed the same steps:<\/p>\n<ol>\n<li>Determine today: <span style=\"font-family: 'courier new', courier, monospace;\">GetCurrentDate()<\/span><\/li>\n<li>Retrieved the calendar events for <em>next month<\/em> by calling <span style=\"font-family: 'courier new', courier, monospace;\">GetEvents(from, to)<\/span><\/li>\n<li>Reason over calendar availability<\/li>\n<\/ol>\n<p>We saw that while the monoagent orchestrated each function call, the microagent approach simply requested from the calendar agent to: <span style=\"font-family: 'courier new', courier, monospace;\">Show me my availability for a four-night stay in Hawaii next month<\/span> (letting the calendar microagent internally manage the steps required to process the request).<\/p>\n<p>On the other hand, we saw the travel microagent engage in a classically iterative interaction as the various flight routes (different islands) were provided to the manager who subsequently initiated the booking request.<\/p>\n<p>With either approach (mono or micro), we found that context is absolutely key.\u00a0 The absence of sufficient contextual data greatly impacts the models ability to reliably sustain task completion.\u00a0 While the microagent pattern provides an opportunity for higher domain proficiency (return trip booking), a mono-agent (by definition) maintains context (by coordinating everything).<\/p>\n<h4>Join us in building agents!<\/h4>\n<p>Explore these ideas by checking out the <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/tree\/main\/dotnet\/src\/Experimental\/Agents\">Semantic Kernel Agents<\/a> package. We&#8217;ll soon release the code and a video walking through the experiments listed in this blog. We&#8217;d love to hear about your experience.<\/p>\n<p>UPDATE: Find the code with a demo application and data on the MicroAgent approach <a href=\"https:\/\/github.com\/crckman\/MicroAgentsDemo\">here.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Throughout our time building Semantic Kernel and working with customers, we&#8217;ve introduced agents and have just started to explore the potential of autonomous AI agents. While the community is in the midst of exploring various architectures for these agents, one source we can draw inspiration from is the microservice architecture. Consider the benefits of microservices: [&hellip;]<\/p>\n","protected":false},"author":124422,"featured_media":1893,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Throughout our time building Semantic Kernel and working with customers, we&#8217;ve introduced agents and have just started to explore the potential of autonomous AI agents. While the community is in the midst of exploring various architectures for these agents, one source we can draw inspiration from is the microservice architecture. Consider the benefits of microservices: [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/1890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/124422"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=1890"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/1890\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/1893"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=1890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=1890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=1890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}