Skip to content

Hold Chat

v1.0.0

The Hold Chat LOP acts as a conversation gatekeeper. It monitors an input conversation table and decides whether to pass it through or block it based on token count thresholds, message count thresholds, or a manual hold toggle. When no hold is active, the input conversation is copied to the output. When any hold condition is met, the output stops updating.

Hold Chat evaluates three independent hold conditions on every cook:

  • Token Hold — counts the total tokens across all messages using tiktoken and compares against a configurable threshold.
  • Message Hold — counts the number of messages and compares against a configurable threshold.
  • Manual Hold — a simple toggle for human-controlled pausing.

If any one of these conditions is active, the operator enters a held state and stops passing the conversation through. When all conditions clear, the conversation is released to the output. Each condition fires its own pair of callbacks (on/off), and the overall hold state fires the general onHold / onHoldEnd callbacks.

  • tiktoken — Python package used for token counting. Install via the ChatTD Python manager.

The operator reads from an internal input_table DAT with columns: role, message, id, timestamp.

  • conversation_dat — When no hold is active, the input table is copied here. Downstream operators can read this output to receive the released conversation.
  1. Wire a conversation table into the Hold Chat operator.
  2. On the Hold page, enable Enable Token Hold.
  3. Set Token Hold Threshold to your desired limit (e.g., 2048 tokens).
  4. As the conversation grows, the Token Total read-only parameter updates automatically.
  5. When the total token count exceeds the threshold, the hold activates and the output stops updating.
  6. Once the input conversation is trimmed below the threshold, the hold releases and the conversation passes through.
  1. On the Hold page, enable Enable Message Hold.
  2. Set Message Hold Threshold to the maximum number of messages allowed.
  3. Message Total updates automatically as messages arrive.
  4. When the message count reaches the threshold, the hold activates.
  1. On the Hold page, toggle Toggle Manual Hold to On.
  2. The Manual Hold read-only indicator turns on, confirming the hold is active.
  3. The output stops updating until you toggle Toggle Manual Hold back to Off.

Enable Lock When Held & Unlock to prevent the operator from recalculating while held. This skips the token and message counting entirely during a hold, which can save processing when conversations are large. When the hold clears, normal evaluation resumes.

Hold Chat fires granular callbacks for each hold type, letting you react to specific threshold crossings independently. The general onHold and onHoldEnd callbacks fire when the overall hold state changes (any hold activating or all holds clearing), while the type-specific callbacks (onTokenThreshold, onMessageThreshold, onManual and their End variants) fire when individual conditions change.

Enable or disable individual callbacks on the Callbacks page using the toggle next to each callback name.

  • Rate limiting — pause a conversation pipeline when token usage gets too high.
  • Content moderation — manually hold conversations for review before they reach downstream agents.
  • Budget protection — set token thresholds that align with API cost limits.
  • Batch processing — accumulate messages until a count threshold is reached, then release them all at once.
Hold Active (Holdactive) op('hold_chat').par.Holdactive Toggle
Default:
False
Toggle Manual Hold (Manualhold) op('hold_chat').par.Manualhold Toggle
Default:
False
Manual Hold (Userhold) op('hold_chat').par.Userhold Toggle
Default:
False
Enable Token Hold (Enabletokenhold) op('hold_chat').par.Enabletokenhold Toggle
Default:
False
Token Hold Threshold (Tokenholdthreshold) op('hold_chat').par.Tokenholdthreshold Int
Default:
2048
Range:
0 to 1
Slider Range:
1 to 8192
Token Total (Tokentotal) op('hold_chat').par.Tokentotal Int
Default:
2048
Range:
0 to 1
Slider Range:
1 to 8192
Token Hold Active (Tokenhold) op('hold_chat').par.Tokenhold Toggle
Default:
False
Enable Message Hold (Enablemessagehold) op('hold_chat').par.Enablemessagehold Toggle
Default:
False
Message Hold Threshold (Messageholdthreshold) op('hold_chat').par.Messageholdthreshold Int
Default:
0
Range:
0 to 1
Slider Range:
0 to 1
Message Total (Messagetotal) op('hold_chat').par.Messagetotal Int
Default:
0
Range:
0 to 1
Slider Range:
0 to 1
Message Hold Active (Messagehold) op('hold_chat').par.Messagehold Toggle
Default:
False
Lock When Held & Unlock (Lockwhenheld) op('hold_chat').par.Lockwhenheld Toggle
Default:
False
Header
Callbacks Header
Callback DAT (Callbackdat) op('hold_chat').par.Callbackdat DAT
Default:
ChatTD_callbacks
Edit Callbacks (Editcallbacksscript) op('hold_chat').par.Editcallbacksscript Pulse
Default:
False
Create Callbacks (Createpulse) op('hold_chat').par.Createpulse Pulse
Default:
False
onHold (Onhold) op('hold_chat').par.Onhold Toggle
Default:
False
onHoldEnd (Onholdend) op('hold_chat').par.Onholdend Toggle
Default:
False
onTokenThreshold (Ontokenthreshold) op('hold_chat').par.Ontokenthreshold Toggle
Default:
False
onTokenThresholdEnd (Ontokenthresholdend) op('hold_chat').par.Ontokenthresholdend Toggle
Default:
False
onMessageThreshold (Onmessagethreshold) op('hold_chat').par.Onmessagethreshold Toggle
Default:
False
onMessageThresholdEnd (Onmessagethresholdend) op('hold_chat').par.Onmessagethresholdend Toggle
Default:
False
onManual (Onmanual) op('hold_chat').par.Onmanual Toggle
Default:
False
onManualEnd (Onmanualend) op('hold_chat').par.Onmanualend Toggle
Default:
False
Textport Debug Callbacks (Debugcallbacks) op('hold_chat').par.Debugcallbacks Menu
Default:
Full Details
Options:
None, Errors Only, Basic Info, Full Details
Available Callbacks:
  • onHold
  • onHoldEnd
  • onTokenThreshold
  • onTokenThresholdEnd
  • onMessageThreshold
  • onMessageThresholdEnd
  • onManual
  • onManualEnd
Example Callback Structure:
def onHold(info):
# Called when any hold becomes active
# info: {'Hold': True}
pass

def onHoldEnd(info):
# Called when all holds become inactive
# info: {'Hold': False}
pass

def onTokenThreshold(info):
# Called when token count exceeds threshold
# info: {'Hold': True, 'Type': 'TokenThreshold'}
pass

def onTokenThresholdEnd(info):
# Called when token count drops below threshold
# info: {'Hold': False, 'Type': 'TokenThreshold'}
pass

def onMessageThreshold(info):
# Called when message count exceeds threshold
# info: {'Hold': True, 'Type': 'MessageThreshold'}
pass

def onMessageThresholdEnd(info):
# Called when message count drops below threshold
# info: {'Hold': False, 'Type': 'MessageThreshold'}
pass

def onManual(info):
# Called when manual hold is activated
# info: {'Hold': True, 'Type': 'ManualHold'}
pass

def onManualEnd(info):
# Called when manual hold is deactivated
# info: {'Hold': False, 'Type': 'ManualHold'}
pass
v1.0.02024-11-10

Initial release