Agent Task Break Detector: knowing when to start a fresh session

A small ModernBERT model that checks every message in an AI agent session and says whether it is a new task a fresh session could handle. Runs locally on CPU; v0.1, trained on synthetic data.

Daniel Rosehill Agents

(23 Cheshvan 5787)

2 min read

Agent Task Break Detector: knowing when to start a fresh session

I'm bad at starting new sessions. I'll be deep into a long Claude Code session on one thing, remember something unrelated, and type it in right there. The agent carries the whole earlier context into a task that needs none of it, which costs tokens and sometimes muddles the answer. The fix is trivial (type /clear first), and I forget to do it nearly every time.

So I trained a model to notice for me. Agent-Task-Break-Detector-ModernBERT answers one question on every user turn: does this message need the conversation so far, or is it a new task that a fresh session could handle just as well?

Hugging Face Model danielrosehill/Agent-Task-Break-Detector-ModernBERT A small cross-encoder that answers one question on every user turn of an AI agent session: ↓ 62Text classificationAPACHE-2.0Updated Oct 2026 View model on Hugging Face

How it works

It's a small cross-encoder, a fine-tune of ModernBERT-base (about 150M parameters). The input is the new message paired with the last four exchanges, newest first, and the output is a probability that the message is a new task. A harness hook can read that number and start a fresh session, or just suggest one, when an unrelated task lands in a long session.

The size was the point. A check that runs on every single turn can't be an API call: it has to be fast, local and free. The int8 ONNX build is 151 MB and runs on a CPU.

Try it

The Space explains the idea and runs the int8 model live, so you can paste in a conversation and a new message and see what it decides:

Live demo, running on Hugging Face. If it is asleep it takes a minute to wake up. Open it full-screen on Hugging Face.
Hugging Face Space danielrosehill/Agent-Task-Break-Detector Does this message need the session so far, or a fresh one? GradioLiveAPACHE-2.0Updated Oct 2026 Open the Space

The caveat

This is v0.1 and experimental. It was trained only on synthetic sessions (the training data is public), and I haven't yet tested it against real, hand-labelled sessions. That's the next step, and the obvious place it will struggle is the grey zone: "while you're at it, can you also..." sits right on the line between a follow-up and a new task, and people disagree about those too.

Hugging Face Dataset danielrosehill/Agent-Task-Break-Detector Synthetic training data for a small classifier that answers one question on every user turn of an AI agent session: ↓ 65Text classificationCC-BY-4.0Updated Oct 2026 View dataset on Hugging Face

The weights are Apache 2.0, and the model ships a small settings file with the recommended threshold, which a Claude Code plugin can read directly. Until it has been tested on real sessions, a hook that suggests a fresh session is a safer use than one that clears the session on its own.

Daniel Rosehill

Daniel Rosehill

Agentic AI systems architect in Jerusalem. I design and build multi-agent systems, MCP tooling and speech-to-text pipelines, and write up what I learn along the way.

More about me at danielrosehill.com