﻿# bb scheduled scripts: start a model only when work appears

A bb script gate can detect whether work exists before using a model; keep skipped, failed and agent-started outcomes distinct and tied to the observed event.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/bb-script-gate-before-agent-job/
Language: en

Some recurring checks have a simple outcome: there is work to investigate, or nothing changed. In bb, a script can make that initial decision before starting a coding agent. The useful mechanism is a gate between a deterministic observation and a model-driven task, with explicit meanings for skipped and failed runs.

## Choose a condition that a script can observe

Imagine watching a project’s CI status. A script can inspect whether the relevant branch has a newly failed run, while a coding agent investigates the failure’s cause. The scheduling guide documents this separation. A good gate checks the smallest condition that justifies further work rather than asking a language model to interpret an unchanged dashboard repeatedly. The condition should identify the branch and run being considered, so unrelated failures do not accidentally start the wrong investigation.

## A quiet result has a defined meaning

The guide describes a script exiting without output as skipped. That result can represent a valid observation that no work was found. It should not be confused with a script that never reached the data source. An error exit or timeout is documented as failed. In the CI example, an authentication failure is therefore different from a healthy branch. Preserving those distinctions makes silence informative instead of allowing missing access to masquerade as a successful empty check.

## Pass the finding into a bounded agent task

When the condition is satisfied, the script can start an agent with the relevant finding. A useful task names the failed run and asks for an explanation or a scoped correction. The gate’s observation is the reason to start, not proof that the model can complete the repair. The agent still needs repository context and verification. This arrangement keeps routine detection separate from the open-ended reasoning needed to connect a CI failure to an implementation change.

## Make repeated observations distinguishable

A periodic gate can encounter the same failure again. A useful engineering design decides whether an active investigation or a previously recorded run should suppress duplicate work. This is an application-level choice, not an undocumented promise that bb deduplicates every external event automatically. Record the observation identity and the resulting task together. The scheduling guide supports script-only checks without a model, while any further efficiency claim depends on the actual workload and how often the gate finds meaningful new work.

## Primary sources

- [Run an agent on a schedule](https://getbb.app/guides/run-an-agent-on-a-schedule).

- [Orchestrate your coding agents](https://getbb.app/guides/orchestrate-coding-agents).

- [bb changelog](https://getbb.app/changelog).

Related engineering context: [Choosing an AI development stack](/journal/local-ai-app-stack-selection/); [Git state and undo](/journal/aider-git-dirty-tree-undo/).
