Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the ReAct agent with the correct reasoning step.
Prompt Engineering / GenAI
agent = ReActAgent(reasoning_steps=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting reasoning_steps to 0 disables reasoning.
Using too many steps initially can complicate the agent's behavior.
✗ Incorrect
The ReAct pattern typically starts with one reasoning step to allow the agent to think and act iteratively.
2fill in blank
mediumComplete the code to add an observation after the agent takes an action.
Prompt Engineering / GenAI
agent.observe(action_output=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not defined or unrelated.
Confusing 'observation' with the variable holding the action output.
✗ Incorrect
The agent observes the result of its action, which is stored in 'action_result'.
3fill in blank
hardFix the error in the code to correctly perform the agent's think-act cycle.
Prompt Engineering / GenAI
thought = agent.think(input_text)
action = agent.act([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the original input instead of the thought.
Passing the action variable before it is defined.
✗ Incorrect
The agent acts based on its thought, so the argument to act() should be the 'thought' variable.
4fill in blank
hardFill both blanks to create a loop that runs the ReAct agent for 3 cycles.
Prompt Engineering / GenAI
for _ in range([1]): thought = agent.think(input_text) action = agent.act(thought) agent.observe([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'thought' instead of 'action' for observation.
Setting the loop count incorrectly.
✗ Incorrect
The loop runs 3 times, and the agent observes the result of its action each cycle.
5fill in blank
hardFill all three blanks to define a function that runs the ReAct agent for a given number of steps and returns the final thought.
Prompt Engineering / GenAI
def run_react_agent(agent, input_text, steps): for _ in range([1]): thought = agent.think(input_text) action = agent.act([2]) agent.observe([3]) return thought
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'input_text' instead of 'thought' for the act method.
Observing 'thought' instead of 'action'.
✗ Incorrect
The loop runs for 'steps' times, the agent acts on 'thought', observes 'action', and finally returns the last thought.