An AI agent built my Spectacles Lens. A second model I wrote showed me my own rules were the problem
DEV Community

An AI agent built my Spectacles Lens. A second model I wrote showed me my own rules were the problem

Rehearse a talk alone and you stare at one spot: a wall, a laptop camera, the door. A real audience sits around you, and the people you ignore are the ones you lose.

I wanted a rehearsal room where that cost is visible, so I built Pandang, a Spectacles Lens: six listeners on cushion seats in an arc where your sofa and chairs would be, and the only input while you talk is where your head points.

An AI agent wrote most of it. This post is about how I checked its work, and about the second model I wrote on the side. That model agreed with the agent's code to three decimal places, and then showed me something about my own rules that none of the agent's tests could.

The rules

  • Hold your view on a listener for 1.5 s and they warm up and nod. A shorter glance does nothing.
  • An ignored listener cools from 8 s after your last look and is fully faded at 15 s. It chimes once as it fades, from a sound source at its own seat, because the glasses show only one or two listeners at a time and the rest need another way to reach you.
  • Press End and every listener keeps a glow for how long they stayed warm. The mean is one big coverage number. At 70 % or more the audience applauds.

Every one of those numbers lives in one file, Assets/Scripts/PandangConfig.ts:

export const DWELL_S = 1.5 // a look this long on one listener lands contact
export const GRACE_S = 0.2 // a gap shorter than this keeps the dwell
export const COOL_START_S = 8 // warmth starts to drop this long after the last contact
export const FADE_END_S = 15 // fully faded (and one chime) this long after the last contact
export const PASS = 0.7 // coverage at or above this is a pass
export const CONE_DEG = 10 // the view centre must be within this angle of a figure to aim at it
export const SEATS : number = 6
export const ARC_SPAN_DEG = 120

Who wrote what

I wrote a design brief first, with the Devpost Learn skill pack, and then CLAD built the Lens. CLAD is a Claude Code plugin that drives Lens Studio through its MCP server.

It took ten prompted turns: the first flow, the chime and applause, LEAF test scenarios for each "done" criterion in the brief, and three polish turns. All ten prompts are published in order in prompts/. Between turns I made smaller fixes directly with Claude Code, and the commit history shows both.

This left me with a trust problem. The agent wrote the attention model and the tests for it. If it misread a rule, the tests would carry the same misreading, and 12/12 green would mean nothing.

A second model, written from the brief alone

So I had a reference model written in Python, with Claude Code, from the brief's rules and nothing else: tests/reference/attention_ref.py. It is deliberately dumb. It uses a fixed 60 Hz step and loops over every seat on every frame:

for i in range ( N ) :
  if aim == i :
    off [ i ] = 0.0
    before = dwell [ i ]
    dwell [ i ] += DT
    if before < DWELL <= dwell [ i ] :
      nods [ i ] += 1 ; contacted [ i ] = True ; armed [ i ] = True
    if dwell [ i ] >= DWELL :
      last [ i ] = t
  else :
    off [ i ] += DT
    if off [ i ] > GRACE :
      dwell [ i ] = 0.0
  age = t - ( last [ i ] if contacted [ i ] else 0.0 )
  if contacted [ i ] and age < COOL_START :
    w = 1.0
  elif contacted [ i ] and age < FADE_END :
    w = 1.0 - ( age - COOL_START ) / ( FADE_END - COOL_START )
  else :
    w = 0.0

The agent's TypeScript is the opposite. It runs at whatever frame rate the device gives it, so it integrates warmth in closed form, and a long frame can't smear a landing:

// contact lands at the instant the dwell reached DWELL_S (exact even across a long frame)
const landedAt = this . nowS - ( this . dwellS - DWELL_S )
const oldLc = this . lastContact [ aimed ]
if ( oldLc !== null )
  this . glowInt [ aimed ] -= warmthIntegral ( this . nowS - oldLc ) - warmthIntegral ( landedAt - oldLc )
this . lastContact [ aimed ] = landedAt
this . glowInt [ aimed ] += warmthIntegral ( this . nowS - landedAt )

Two implementations with different structure and different time handling, written separately from the same text: CLAD wrote the TypeScript in its first turn, and the Python was written separately with Claude Code.

The Python model generates the fixtures the LEAF scenarios assert, and check-fixtures.sh regenerates them and confirms they are byte-identical to the checked-in file. The two models agree to within 0.001 coverage on every fixture.

That agreement was the result I was looking for. The more useful one came next.

What the reference model said about my rules

Once I had a cheap, fast model, I could ask questions no LEAF test asks. The main one: what does a natural speaker score? attention_ref.py --pace simulates a presenter going round the room, holding each listener for a fixed time with 0.4 s to turn between them:

P_round_robin_2.0s_30s cov=0.6369 pass=False dim=[2, 3, 4, 5] chimes=0
P_round_robin_2.0s_60s cov=0.7316 pass=True dim=[4, 5] chimes=0
P_round_robin_2.0s_180s cov=0.7950 pass=True dim=[] chimes=0
P_round_robin_2.5s_60s cov=0.6339 pass=False dim=[1, 2, 3, 4, 5] chimes=16
P_round_robin_3.0s_60s cov=0.5626 pass=False dim=[0, 1, 2, 3, 4, 5] chimes=15
P_ignore_half_1.8s_60s cov=0.4644 pass=False dim=[3, 4, 5] chimes=3
P_stare_one_60s cov=0.1611 pass=False dim=[0, 1, 3, 4, 5] chimes=5

A brisk 2 s per listener passes once a run reaches about a minute. A relaxed 3 s per listener fails at every length from 30 s to 3 minutes. At 2.5 s, the room chimes 16 times in a minute.

The arithmetic is simple once you see it. Six listeners at 2 s each plus 0.4 s per turn is a lap of about 14 s. Cooling starts at 8 s, so every listener starts to cool on every lap, even for a perfectly even speaker. The 15 s fade is the only signal of real neglect, and a slow speaker crosses it.

None of the agent's tests could have found this. They test that the code follows the rules, and it does, exactly. The problem was in the rules.

I kept the brief's numbers anyway. Tuning them until my own demo passed comfortably would have been easy. Instead, the limit is in the README as honest limit #2, with the command that reproduces it. Changing the rules is a design decision that needs a real person wearing real glasses, not a number fitted to a preview.

The aim resolver, swept exhaustively

The other half of the logic decides which listener you are looking at: you aim at one when the centre of the view is within 10° of it. Edge cases hide in geometry, so I ran the resolver on every view direction on a 0.1° grid instead of sampling. That is 6,413,381 directions, each checked against five invariants:

  • I1 a returned seat is within CONE_DEG and has the smallest angular error of all seats
  • I2 no ray is ever within CONE_DEG of two seats (the aim cones never overlap)
  • I3 a returned seat is never behind the button
  • I4 a null result means no seat is in the cone, or the button is in front of the best seat
  • I5 left/right mirror symmetry: yaw -> -yaw maps seat i to seat (SEATS-1-i)

Result: 0 violations. 378,124 directions aim at a listener and 11,406 are blocked by the End button. It runs on every push in CI, on Node 20 and 22, next to the 38 pure checks and the fixture check.

Then an AI judge called them chess pawns

The logic was solid; the look was not. I ran CLAD's own lens-evaluation skill, which scores a Lens with five AI judge personas. The panel gave 7.00/10 and rated visual and asset quality lowest.

The critic's line: "The attention model runs like a Swiss watch; the audience is six chess pawns that blush on cue."

That was fair. Prompt 08 was written straight from its top fixes: warmer, solid waiting figures; a nod you can actually see; seated figures with a lap and forearms; idle breathing. Prompts 09 and 10 came from design reviews of preview stills after each turn. LEAF stayed at 12/12 after every turn. I didn't re-run the evaluation after the polish, so I don't claim a new score.

Honest limits

  • Preview only. I had no Spectacles device. Gaze in the preview is a mouse-driven or scripted view, so I haven't tested how a 1.5 s head dwell feels while you're really talking. Each chime plays from its seat's position, but nobody has checked by ear that you can hear the direction.
  • A relaxed pace fails, as shown above. The numbers stay as the brief set them.
  • The seats are stand-ins. Six cushion blocks represent your sofa and chairs; the Lens doesn't find real furniture.

What I'd take from this

When an agent writes both your logic and your tests, write a second model yourself from the spec, as different as you can make it. Agreement tells you the agent read the spec the way you did. The model also lets you ask questions about the spec that the agent's tests never ask, and in my case that is where the real finding was.

Watch the demo:

Judge guide, 30 seconds: https://pandang.edycu.dev/judge

Code, logs and all ten prompts: https://github.com/edycutjong/pandang

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.