31  Sub-agents for plotting and writing methods

The analysis skill from the last module produces a fitted model. What happens next — plotting it, writing it up — are different jobs with different failure modes, and giving them to separately scoped sub-agents rather than one agent holding everything at once tends to produce more consistent output.

31.1 Splitting the task

Instead of one agent doing modelling, plotting, and write-up in a single long session, delegate two narrower roles:

  • Plotting sub-agent — given only the fitted model object (not the raw data, not the modelling decisions behind it), produce a ggplot of predicted pres.topa against CB_cover with confidence intervals, using visreg::visreg(m, "CB_cover", gg = TRUE) as a starting point.
  • Methods-writing sub-agent — given only the model summary output (family, formula, dispersion, coefficients — not the raw dataset), write a two-sentence methods paragraph describing what was fitted and why.
NotePrompt (plotting sub-agent)

Here is a fitted model object m (MASS::glm.nb(pres.topa ~ CB_cover, data = fish_coral_cover_sites)). Produce a ggplot of the predicted relationship with confidence intervals using visreg. Do not refit or modify the model.

NotePrompt (methods sub-agent)

Here is the summary() output of a fitted negative binomial GLM (formula, coefficients, dispersion parameter). Write a two-sentence methods paragraph suitable for a results section, stating the model family, the response and predictor, and why that family was chosen.

31.2 Why scope the context narrowly

Handing the writing sub-agent only the model summary — not the full dataset or script history — isn’t just tidiness. An agent with the whole project in context will sometimes “helpfully” second-guess a modelling decision it wasn’t asked to review, or fold in details from an earlier draft that no longer apply. Narrowing what a sub-agent can see narrows what it can go wrong about.

This is the same context-poisoning concern from Section 2, applied deliberately — a fresh, narrowly-scoped sub-agent can’t inherit a mistake from an earlier stage of the pipeline it never saw.

ImportantChallenge

Run the two-sub-agent split above on the topa/coral-cover model, then run the same plotting-and-writing task with a single unscoped agent that has the whole project in context. Compare the two methods paragraphs and two plots — what’s different, and which would you trust more without checking further?