Table of Contents
Fetching ...

What You Need is What You Get: Theory of Mind for an LLM-Based Code Understanding Assistant

Jonan Richards, Mairieli Wessel

TL;DR

This work tackles the challenge of making LLM-powered code understanding tools effective for novices by inferring and leveraging the developer's mental state. It introduces ToMMY, a three-prompt Theory-of-Mind prompting architecture that personalizes explanations based on inferred user background and preferences, and compares it to a basic agent in a within-subject study with 14 novices. The results reveal nuanced effects: interaction style significantly shapes ToMMY's impact on code understanding, with benefits depending on how users question the system. The study contributes a concrete design for mind-aware explanations and highlights future directions in memory, retrieval-augmented state tracking, and transparency to improve human-AI code collaboration.

Abstract

A growing number of tools have used Large Language Models (LLMs) to support developers' code understanding. However, developers still face several barriers to using such tools, including challenges in describing their intent in natural language, interpreting the tool outcome, and refining an effective prompt to obtain useful information. In this study, we designed an LLM-based conversational assistant that provides a personalized interaction based on inferred user mental state (e.g., background knowledge and experience). We evaluate the approach in a within-subject study with fourteen novices to capture their perceptions and preferences. Our results provide insights for researchers and tool builders who want to create or improve LLM-based conversational assistants to support novices in code understanding.

What You Need is What You Get: Theory of Mind for an LLM-Based Code Understanding Assistant

TL;DR

This work tackles the challenge of making LLM-powered code understanding tools effective for novices by inferring and leveraging the developer's mental state. It introduces ToMMY, a three-prompt Theory-of-Mind prompting architecture that personalizes explanations based on inferred user background and preferences, and compares it to a basic agent in a within-subject study with 14 novices. The results reveal nuanced effects: interaction style significantly shapes ToMMY's impact on code understanding, with benefits depending on how users question the system. The study contributes a concrete design for mind-aware explanations and highlights future directions in memory, retrieval-augmented state tracking, and transparency to improve human-AI code collaboration.

Abstract

A growing number of tools have used Large Language Models (LLMs) to support developers' code understanding. However, developers still face several barriers to using such tools, including challenges in describing their intent in natural language, interpreting the tool outcome, and refining an effective prompt to obtain useful information. In this study, we designed an LLM-based conversational assistant that provides a personalized interaction based on inferred user mental state (e.g., background knowledge and experience). We evaluate the approach in a within-subject study with fourteen novices to capture their perceptions and preferences. Our results provide insights for researchers and tool builders who want to create or improve LLM-based conversational assistants to support novices in code understanding.
Paper Structure (11 sections, 3 figures, 5 tables)

This paper contains 11 sections, 3 figures, 5 tables.

Figures (3)

  • Figure 1: Web-based interface designed for the experiment
  • Figure 2: Distribution of question targets, broken down by participants who did not (left) and did (right) use hypotheses.
  • Figure 3: Distribution of response length, broken down by model and whether or not the question was phrased as a hypothesis.