State-scoped tools
config.tools is the authority. A tool is only advertised if the state, its registry gates and its condition allow it.
Decide which tools an LLM can see in each conversation state, with a small state machine and a per-step tool budget.
npm install reactive-fsmRequires Node 20+.
import { createFSM } from 'reactive-fsm'
const fsm = createFSM({
initialState: 'IDENTITY',
states: ['IDENTITY', 'BOOKING'] as const,
tools: {
IDENTITY: ['validate_dni'],
BOOKING: ['check_availability'],
},
loopShield: { enabled: true, maxConsecutiveTools: 3 },
})
fsm.transitionTo('BOOKING')
fsm.allowedTools // ['check_availability']