AgentsAuthors:JuliaWiesinger,PatrickMarlowandVladimirVuskovicAgents2September2024AcknowledgementsReviewersandContributorsEvanHuangEmilyXueOlcanSercinogluSebastianRiedelSatinderBavejaAntonioGulliAnantNawalgariaCuratorsandEditorsAntonioGulliAnantNawalgariaGraceMollisonTechnicalWriterJoeyHaymakerDesignerMichaelLanningIntroduction4Whatisanagent?5Themodel6Thetools7Theorchestrationlayer7Agentsvs.models8Cognitivearchitectures:Howagentsoperate8Tools:Ourkeystotheoutsideworld12Extensions13SampleExtensions15Functions18Usecases21Functionsamplecode24Datastores27Implementationandapplication28Toolsrecap32Enhancingmodelperformancewithtargetedlearning33AgentquickstartwithLangChain35ProductionapplicationswithVertexAIagents38Summary40Endnotes42TableofcontentsAgents4September2024IntroductionHumansarefantasticatmessypatternrecognitiontasks.However,theyoftenrelyontools-likebooks,GoogleSearch,oracalculator-tosupplementtheirpriorknowledgebeforearrivingataconclusion.Justlikehumans,GenerativeAImodelscanbetrainedtousetoolstoaccessreal-timeinformationorsuggestareal-worldaction.Forexample,amodelcanleverageadatabaseretrievaltooltoaccessspecificinformation,likeacustomer'spurchasehistory,soitcangeneratetailoredshoppingrecommendations.Alternatively,basedonauser'squery,amodelcanmakevariousAPIcallstosendanemailresponsetoacolleagueorcompleteafinancialtransactiononyourbehalf.Todoso,themodelmustnotonlyhaveaccesstoasetofexternaltools,itneedstheabilitytoplanandexecuteanytaskinaself-directedfashion.Thiscombinationofreasoning,logic,andaccesstoexternalinformationthatareallconnectedtoaGenerativeAImodelinvokestheconceptofanagent,oraprogramthatextendsbeyondthestandalonecapabilitiesofaGenerativeAImodel.Thiswhitepaperdivesintoalltheseandassociatedaspectsinmoredetail.Thiscombinationofreasoning,logic,andaccesstoexternalinformationthatareallconnectedtoaGenerativeAImodelinvokestheconceptofanagent.Agents5September2024Whatisanagent?Initsmostfundamentalform,aGenerativeAIagentcanbedefinedasanapplicationthatattemptstoachieveagoalbyobservingtheworldandactinguponitusingthetoolsthatithasatitsdisposal.Agentsareautonomousandcanactindependentlyofhumanintervention,especiallywhenprovidedwithpropergoalsorobjectivestheyaremeanttoachieve.Agentscanalsobeproactiveintheirapproachtoreachingtheirgoals.Evenintheabsenceofexplicitinstructionsetsfromahuman,anagentcanreasonaboutwhatitshoulddonexttoachieveitsultimategoal.WhilethenotionofagentsinAIisquitegeneralandpowerful,thiswhitepaperfocusesonthespecifictypesofagentsthatGenerativeAImodelsarecapableofbuildingatthetimeofpublication.Inordertounderstandtheinnerworkingsofanagent,let’sfirstintroducethefoundationalcomponentsthatdrivetheagent’sbehavior,actions,anddecisionmaking.Thecombinationofthesecomponentscanbedescribedasacognitivearchitecture,andtherearemanysucharchitecturesthatcanbeachievedbythemixingandmatchingofthesecomponents.Focusingonthecorefunctionalities,therearethreeessentialcomponentsinanagent’scognitivearchitectureasshowninFigure1.Agents6September2024Figure1.GeneralagentarchitectureandcomponentsThemodelInthescopeofanagent,amodelreferstothelanguagemodel(LM)thatwillbeutilizedasthecentralizeddecisionmakerforagentprocesses.ThemodelusedbyanagentcanbeoneormultipleLM’sofanysize(small/large)thatarecapableoffollowinginstructionbasedreasoningandlogicframeworks,likeReAct,Chain-of-Thought,orTree-...