Write pseudocode for a ReAct-style loop

Quick Overview

This question evaluates the ability to design a ReAct-style agent control loop and related competencies such as state management, tool orchestration, observation handling, error management, and safeguards for termination and resource limits.

Write pseudocode for a ReAct-style loop

Company: Zillow

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Coding prompt (pseudocode) Write **pseudocode** (does not need to compile) for a **ReAct-style agent loop** that alternates between **reasoning** and **actions**. ### Requirements - The agent receives a **user question**. - On each iteration, the model produces something like: - `Thought`: internal reasoning about what to do next - `Action`: the name of a tool to call (e.g., `Search`, `Calculator`, `LookupDB`) or `Finish` - `ActionInput`: arguments for the tool - If an `Action` is chosen: - Call the tool, obtain an `Observation`. - Append `Observation` back into the context for the next iteration. - Stop when the model chooses `Finish` or when a maximum number of steps is reached. - Include basic safeguards: - max steps / timeouts - handling tool errors - preventing infinite loops ### Deliverable Provide the loop structure and the data you keep in state (e.g., conversation history, scratchpad, tool outputs).

Quick Answer: This question evaluates the ability to design a ReAct-style agent control loop and related competencies such as state management, tool orchestration, observation handling, error management, and safeguards for termination and resource limits.

|Home/Coding & Algorithms/Zillow
Zillow logo
Zillow
Nov 8, 2025, 12:00 AM
mediumMachine Learning EngineerTechnical ScreenCoding & Algorithms
5
0

Coding prompt (pseudocode)

Write pseudocode (does not need to compile) for a ReAct-style agent loop that alternates between reasoning and actions.

Requirements

  • The agent receives a user question .
  • On each iteration, the model produces something like:
    • Thought : internal reasoning about what to do next
    • Action : the name of a tool to call (e.g., Search , Calculator , LookupDB ) or Finish
    • ActionInput : arguments for the tool
  • If an Action is chosen:
    • Call the tool, obtain an Observation .
    • Append Observation back into the context for the next iteration.
  • Stop when the model chooses Finish or when a maximum number of steps is reached.
  • Include basic safeguards:
    • max steps / timeouts
    • handling tool errors
    • preventing infinite loops

Deliverable

Provide the loop structure and the data you keep in state (e.g., conversation history, scratchpad, tool outputs).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...