Skip to content

AI Agents

Systems to learn:

  1. SuperAGI
  2. AgentGPT
  3. Auto-GPT
  4. gpt-engineer
  5. agent-actors
  6. llm_agents

Key Components

  1. Planning
    1. subgoal & decomposition
    2. reflection & refinement
  2. Memory: short term & long term
  3. Tool Use: external apis

Task Decomposition

Techniques: Chain-of-thought & Tree-of-thought

  1. by LLM with simple prompting like "Steps for XYZ.\n" or "What are the subgoals for achieving XYZ?"
  2. by using task-specific instructions; e.g. "Write a story outline." for writing a novel
  3. with human inputs.

Reflection

Techniques: ReAct, Reflexion, Chain-of-hindsight

Thought: ...
Action: ...
Observation: ...
... (Repeated many times)

Tool(api) usage

  1. Ability to call the API: given description, whether it can invoke api correctly
  2. Ability to retrieve the API: be able to find the appropriate api
  3. Ability to plan API calls: invoke multiple api calls to accomple a vague user request

Core

llm_agents' agent loop:

num_loops = 0
while num_loops < self.max_loops:
    num_loops += 1
    curr_prompt = prompt.format(previous_responses='\n'.join(previous_responses))
    generated, tool, tool_input = self.decide_next_action(curr_prompt)
    if tool == 'Final Answer':
        return tool_input
    if tool not in self.tool_by_names:
        raise ValueError(f"Unknown tool: {tool}")
    tool_result = self.tool_by_names[tool].use(tool_input)
    generated += f"\n{OBSERVATION_TOKEN} {tool_result}\n{THOUGHT_TOKEN}"
    previous_responses.append(generated)
  1. Construct prompt from previous actions & results
  2. Make a decision on which tools to use and input arguments
  3. Execute the tool with the arguments, and use the output as an observation
  4. Another call to LLM to do a thought

References

  1. Intelligent agents guided by LLMs
  2. LlamaIndex Data Agent