Intro to AI coding assistants

Programming with LLMs for Data Practitioners

Julia Silge | Posit PBC

Hello!

@juliasilge

@juliasilge.com

juliasilge.com

Day 2: Build with AI

  1. Intro to AI coding assistants (this session!)
  2. Working in your editor
  3. Steering and extending
  4. Agentic workflows

Where we left off

  • Yesterday we ended by sitting with the tension of real promise and also real harms
  • Today we go deeper into the most powerful (and most fraught!) way to work
  • The plan: let’s stay honest and stay in control

From “build on” to “build with”

  • Day 1: you wrote code that calls LLMs (ellmer / chatlas)
  • Day 2: AI assistants help you write and run code, on your own data
  • Same models, a new way of working

A ladder of context

How most of us start

  • Web chat: paste text into ChatGPT and copy paste back
  • Chat in your editor: assistant can see your files, session, and errors
  • Inline completions: assistant suggests code right where you are typing
  • Agents: fetch their own context and act in a loop
  • Going up the ladder, the assistant sees more of your world

When to reach for which

  • Web chat: quick, throwaway questions (or maybe never?)
  • Editor chat: questions and edits grounded in your real code
  • Completions: small and in-flow where you stay fully in control
  • Agents: multi-step work you would otherwise do by hand
  • Two dials, not one
    • How much it sees
    • How much it does

What is an agent?

An LLM in a harness

  • We built up to this yesterday by learning about turns, conversations, tools
  • Harness: the program that wraps the model and runs its tools
    • a web chat, an assistant in your editor, a command-line tool
  • Agent: an LLM in a harness that calls tools in a loop, deciding each step from the last result
  • An agent needs a read tool (to observe) and a write tool (to act)

The question that follows us

  • An agent is not useful unless it can take actions on your behalf
  • But how do you know it is taking the right actions?
  • We will keep returning to this all day: read vs. write, plans, tests, control

Meet Posit Assistant

One assistant, many surfaces

  • A data-science assistant for Positron, RStudio, and the terminal
  • Bring your own LLM
    • We’ll continue to use Anthropic in our workshop
  • It knows about your R or Python session
    • For example, it can inspect your data frames and their schemas
  • We’ll use Posit Assistant for three things
    • Explore your data
    • Build a dashboard
    • Debug and fix code

The top of the ladder, in one tool

  • Editor chat, completions, and a full agentic loop, all in one place
  • No more copy-pasting from a browser
  • This is the tool we will use all day
  • One assistant, one dataset, climbing from assisted to autonomous

Setting up Posit Assistant

Your turn

Activity

Get set up with Posit Assistant:

  • Open Positron or RStudio and enable Posit Assistant
  • Configure your model provider
  • Confirm it responds: ask it to say hello
10:00

Cost and context

Remember tokens?

  • Every turn replays the whole conversation and you pay per token
  • Cached input is cheap and the output tokens are the expensive part
  • Agents have long conversations, so this matters even more
  • /context shows your usage
  • /compact summarizes to save tokens

Context is the key to good help

  • The assistant works best with high-signal context
  • It already sees your environment including data, plots, errors
  • So let it fetch what it needs; do not paste everything
  • Give it what matters, trim what does not

Demo

How do cached input vs. output tokens drive the cost of a long, agentic conversation?

Walk through Simon’s interactive cost explainer

First contact

Our dataset: Utah crashes

  • About 250,000 crashes, 2016 to 2019, from the Utah Open Data Portal
  • Severity, location, and risk factors
    • DUI, distraction, night, teen driver, and more
  • We will explore it, build on it, and (carefully) let an agent loose on it

Your turn

Activity

Start a chat with Posit Assistant and let it do the loading:

  • Ask: “Read data/utah-crash-data-2020.parquet and tell me what is in it. What are the columns, and what might be interesting to explore?”
  • Notice that it loads and inspects the data itself and you do not need to paste anything
  • Try a follow-up question about something it mentions
10:00

The rest of today

  • Working in your editor:
    • Completions, chat, explore and debug
  • Steering and extending:
    • Plans, memory, skills, and MCP
  • Agentic workflows:
    • More autonomy, with guardrails and reproducible output
  • From assisted to autonomous, one crash dataset the whole way

Thanks!

@juliasilge

@juliasilge.com

juliasilge.com