This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Quest Agent is an AI agent that plays interactive fiction games using large language models and TextWorld. The agent uses the OpenAI SDK to interact with text-based adventure games, employing a tool-calling approach to perform game actions.
- CLI Entry Point (
src/questagent/cli.py): Main command-line interface that orchestrates game episodes - Agent Implementation (
src/questagent/agents.py): ContainsAgentWithToolsclass that implements the TextWorld agent interface - Game Instructions (
resources/instructions.mustache): Mustache template containing the system prompt for the AI agent - Game Files (
games/): Contains interactive fiction game files (e.g.,.ulxformat)
- Uses TextWorld environment for game interaction
- Direct OpenAI SDK integration for decision-making
- Tool-calling pattern: agent uses
perform_game_actiontool to execute game commands - Message history management for conversation context
- Episode-based execution with configurable parameters
# Install dependencies
uv sync
# Add a dependency
uv add openai# Run with test game (game path and model are required)
uv run agent games/test_game.ulx --model gpt-4o-mini
# Run with custom max steps
uv run agent games/test_game.ulx --model gpt-4o-mini --max-steps 100
# Run multiple episodes
uv run agent games/test_game.ulx --model gpt-4o-mini --episodes 5- Requires
.envfile with OpenAI API key - Python 3.13+ required
- Key dependencies: openai, textworld, gym, chevron
- Don't include comments in generated code unless asked explicitly
- Add documentation for functions and classes (docstrings for Python methods)
- Plan implementation before starting and confirm before proceeding
- Get right to the point in communications
- Interactive fiction games in
.ulxformat are supported - Agent receives observations, scores, and game state information
- Actions are executed through the
perform_game_actiontool - Game completion is detected by "*** The End ***" marker or win/loss flags
- Agent maintains conversation history between game turns