Many flexible behaviors are thought to rely on internal representations of an animal’s spatial relationship to its environment and of the consequences of its actions in that environment. While such representations—e.g. of head direction and value—have been extensively studied, how they are combined to guide behavior is not well understood. I will discuss how we are exploring these questions using a classical visual learning paradigm for the fly. I’ll begin by describing a simple policy that, when tethered to an internal representation of heading, captures structured behavioral variability in this task. I’ll describe how ambiguities in the fly’s visual surroundings affect its perception and, when coupled to this policy, manifest in predictable changes in behavior. Informed by newly-released connectomic data, I’ll then discuss how these computations might be carried out and combined within specific circuits in the fly’s central brain, and how perception and action might interact to shape individual differences in learning performance.