← Zillow Interview Insights

Zillow·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Applied Scientist interview at Zillow that included a pseudocode design question around building an agent loop. Pretty technical and open-ended, which I wasn't fully expecting for the format.

Questions Asked (1)

Q1

Write a ReAct-style agent loop in pseudocode. The loop should cycle through Thought, Action, and Observation steps, show how the LLM prompt gets constructed each turn, how tool outputs get appended to the running trajectory, and how the loop eventually terminates (either via a final answer or a step budget limit).

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This one took me a second to get my footing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the core ReAct loop structure: initialize the trajectory, then iteratively construct a prompt from the trajectory, call the LLM, parse the output for Thought/Action, execute the action, append the Observation, and check for termination. Use clear pseudocode with comments to show how the prompt is built and how the trajectory grows, and explicitly handle both final answer and step budget termination.

Pro tip: Mention that you'd cap the trajectory length or summarize past steps to avoid exceeding the LLM's context window, and log each step for debugging—this shows production awareness beyond the basic algorithm.

1. Initialize trajectory and step counter

Create an empty list to store the trajectory (Thought/Action/Observation triples) and set a step counter to 0. Define the maximum step budget.

2. Construct prompt from trajectory

Build the LLM prompt by concatenating the system instructions, the user query, and all previous steps in the trajectory. Format it so the LLM can continue the pattern.

3. Call LLM and parse output

Send the prompt to the LLM and parse the response to extract either a Thought followed by an Action, or a Final Answer. Handle parsing errors gracefully.

4. Execute action and append observation

If an Action is present, execute the corresponding tool with the given input, capture the output, and append the Thought, Action, and Observation to the trajectory.

5. Check termination conditions

If a Final Answer is parsed, return it and exit. If the step counter reaches the budget, return a failure or the best answer so far. Otherwise, increment the counter and loop back to step 2.

Key Points to Mention

  • Prompt construction: include system instructions, user query, and full trajectory with clear delimiters.
  • Trajectory management: append each Thought, Action, and Observation as a new block to maintain context.
  • Tool execution: map action names to actual functions and handle errors or invalid actions.
  • Termination: explicit check for 'Final Answer:' in LLM output, and a max_steps guard to prevent infinite loops.
  • Pseudocode clarity: use indentation, comments, and descriptive variable names to make the loop easy to follow.
  • Edge cases: handle LLM output that doesn't follow the format, and consider truncating or summarizing the trajectory if it gets too long.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.