New Task Split
Claude Code hook: a local ONNX classifier detects an unrelated new task and moves it to a fresh session
About This Project
New-Task-Split is a prototype Claude Code plugin, released as v0.1, that addresses context pollution in long-running agent sessions. When a user submits a prompt unrelated to the work already in progress, the plugin detects the topic change and moves that prompt into a fresh session by sending /clear and re-submitting it. Each task can therefore keep a clean context. The plugin can also be trialled for a single session through a launcher script, and it can be set to a log-only shadow mode that records what it would have split without acting.
Each prompt is scored locally by a small int8 ONNX cross-encoder based on ModernBERT-base, trained on a synthetic dataset of agent task breaks. The model input is the new prompt together with the last one to four prompt and reply exchanges, with the window configurable and defaulting to four. Inference requires no per-turn API calls. The implementation is written in Python, uses onnxruntime and tokenizers, and supports tmux, Konsole over D-Bus, and a clipboard fallback for other terminals. The hook fails open, so any error or disabled configuration lets the prompt pass unchanged. Prompts under 40 characters and sessions with fewer than two earlier prompts are never split. Undo is available through the session resume command, and the model can be updated or pinned to a specific Hugging Face revision.
The project suits developers who run extended Claude Code sessions across mixed tasks and want to test automatic context separation on their own workflow. The README states that the model has been evaluated only on synthetic validation and test data, with reported test precision of 0.94 and recall of 0.89 at threshold 0.76, and that real-session accuracy is unknown. It supports English only, takes about 1.5 seconds per prompt on CPU, and is released under MIT for the plugin, Apache-2.0 for the model, and CC BY 4.0 for the dataset.