In an agent API design pattern, what is the primary role of the 'Planner' component?
Think about which part of the agent figures out what to do next.
The 'Planner' is responsible for deciding the sequence of steps or actions the agent should take to reach its goal. It plans the path forward.
What will be the output of the following agent API code snippet when the action 'fetch_data' fails?
class Agent: def __init__(self): self.actions = {'fetch_data': self.fetch_data} def fetch_data(self): raise Exception('Network error') def execute(self, action_name): try: return self.actions[action_name]() except Exception as e: return f'Error: {e}' agent = Agent() result = agent.execute('fetch_data') print(result)
Look at the except block and what it returns.
The execute method catches the exception and returns a string starting with 'Error:' followed by the exception message.
Which agent API design pattern best supports dynamic switching between multiple tasks based on real-time input?
Consider which pattern allows flexible control and task management.
The hierarchical pattern allows the agent to delegate tasks and switch dynamically based on input, supporting complex decision-making.
In an agent API design, setting a 'timeout' hyperparameter controls:
Think about what 'timeout' usually means in computing.
The 'timeout' sets how long the agent waits for an action to finish before stopping it to avoid hanging.
An agent API is designed to return a JSON response with keys 'status' and 'result'. The following code snippet returns {'status': 'success'} but misses 'result'. What is the likely cause?
def agent_response(data):
if data:
return {'status': 'success'}
else:
return {'status': 'fail', 'result': None}
response = agent_response({'task': 'run'})
print(response)Check what keys are returned in each branch of the function.
The success branch returns only 'status' without 'result', so the response is missing that key.
