PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Cohere

Build an LLM-driven text-game agent

Last updated: May 10, 2026

Quick Overview

This question evaluates a candidate's understanding of integrating large language models into interactive agents, including prompt design, game-state summarization and serialization, constrained action parsing, retry and fallback strategies, context-window management, logging and experiment tracing, testing, and debugging of failure modes.

  • medium
  • Cohere
  • Software Engineering Fundamentals
  • Machine Learning Engineer

Build an LLM-driven text-game agent

Company: Cohere

Role: Machine Learning Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

You are given a terminal-based text game and a several-hundred-line Python baseline that uses hand-written heuristic rules to choose actions. Replace the heuristic agent with an agent that queries an LLM to decide the next action. Describe how you would implement this in Python so that the system is robust and debuggable. Your answer should cover: - the interface between the game engine and the LLM agent - how game state should be summarized and serialized into prompts - how to constrain valid actions and parse model outputs safely - retries, fallbacks, and context-window management - logging, tracing, and experiment tracking - how you would test the agent over repeated runs - how you would debug failures such as invalid actions, infinite loops, or hallucinated state

Quick Answer: This question evaluates a candidate's understanding of integrating large language models into interactive agents, including prompt design, game-state summarization and serialization, constrained action parsing, retry and fallback strategies, context-window management, logging and experiment tracing, testing, and debugging of failure modes.

Cohere logo
Cohere
Dec 25, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Software Engineering Fundamentals
4
0
Loading...

You are given a terminal-based text game and a several-hundred-line Python baseline that uses hand-written heuristic rules to choose actions. Replace the heuristic agent with an agent that queries an LLM to decide the next action.

Describe how you would implement this in Python so that the system is robust and debuggable. Your answer should cover:

  • the interface between the game engine and the LLM agent
  • how game state should be summarized and serialized into prompts
  • how to constrain valid actions and parse model outputs safely
  • retries, fallbacks, and context-window management
  • logging, tracing, and experiment tracking
  • how you would test the agent over repeated runs
  • how you would debug failures such as invalid actions, infinite loops, or hallucinated state

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Cohere•More Machine Learning Engineer•Cohere Machine Learning Engineer•Cohere Software Engineering Fundamentals•Machine Learning Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.