feat(agent): add human-like delay between block replies

Adds `agent.humanDelay` config option to create natural rhythm between
streamed message bubbles. When enabled, introduces a random delay
(default 800-2500ms) between block replies, making multi-message
responses feel more like natural human texting.

Config example:
```json
{
  "agent": {
    "blockStreamingDefault": "on",
    "humanDelay": {
      "enabled": true,
      "minMs": 800,
      "maxMs": 2500
    }
  }
}
```

- First message sends immediately
- Subsequent messages wait a random delay before sending
- Works with iMessage, Signal, and Discord providers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lloyd
2026-01-07 22:56:46 -05:00
committed by Peter Steinberger
parent 22144cd51b
commit ab994d2c63
18 changed files with 206 additions and 60 deletions

View File

@@ -104,6 +104,9 @@ const FIELD_LABELS: Record<string, string> = {
"agents.defaults.model.fallbacks": "Model Fallbacks",
"agents.defaults.imageModel.primary": "Image Model",
"agents.defaults.imageModel.fallbacks": "Image Model Fallbacks",
"agents.defaults.humanDelay.mode": "Human Delay Mode",
"agents.defaults.humanDelay.minMs": "Human Delay Min (ms)",
"agents.defaults.humanDelay.maxMs": "Human Delay Max (ms)",
"commands.native": "Native Commands",
"commands.text": "Text Commands",
"commands.restart": "Allow Restart",
@@ -177,6 +180,12 @@ const FIELD_HELP: Record<string, string> = {
"Optional image model (provider/model) used when the primary model lacks image input.",
"agents.defaults.imageModel.fallbacks":
"Ordered fallback image models (provider/model).",
"agents.defaults.humanDelay.mode":
'Delay style for block replies ("off", "natural", "custom").',
"agents.defaults.humanDelay.minMs":
"Minimum delay in ms for custom humanDelay (default: 800).",
"agents.defaults.humanDelay.maxMs":
"Maximum delay in ms for custom humanDelay (default: 2500).",
"commands.native":
"Register native commands with connectors that support it (Discord/Slack/Telegram).",
"commands.text": "Allow text command parsing (slash commands only).",

View File

@@ -22,6 +22,15 @@ export type BlockStreamingCoalesceConfig = {
idleMs?: number;
};
export type HumanDelayConfig = {
/** Delay style for block replies (off|natural|custom). */
mode?: "off" | "natural" | "custom";
/** Minimum delay in milliseconds (default: 800). */
minMs?: number;
/** Maximum delay in milliseconds (default: 2500). */
maxMs?: number;
};
export type SessionSendPolicyAction = "allow" | "deny";
export type SessionSendPolicyMatch = {
provider?: string;
@@ -922,6 +931,8 @@ export type AgentConfig = {
workspace?: string;
agentDir?: string;
model?: string;
/** Human-like delay between block replies for this agent. */
humanDelay?: HumanDelayConfig;
identity?: IdentityConfig;
groupChat?: GroupChatConfig;
subagents?: {
@@ -1317,6 +1328,8 @@ export type AgentDefaultsConfig = {
* idleMs: wait time before flushing when idle.
*/
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
/** Human-like delay between block replies. */
humanDelay?: HumanDelayConfig;
timeoutSeconds?: number;
/** Max inbound media size in MB for agent-visible attachments (text note or future image attach). */
mediaMaxMb?: number;
@@ -1426,6 +1439,7 @@ export type ClawdbotConfig = {
bindings?: AgentBinding[];
broadcast?: BroadcastConfig;
audio?: AudioConfig;
routing?: RoutingConfig;
messages?: MessagesConfig;
commands?: CommandsConfig;
session?: SessionConfig;

View File

@@ -103,6 +103,14 @@ const BlockStreamingCoalesceSchema = z.object({
idleMs: z.number().int().nonnegative().optional(),
});
const HumanDelaySchema = z.object({
mode: z
.union([z.literal("off"), z.literal("natural"), z.literal("custom")])
.optional(),
minMs: z.number().int().nonnegative().optional(),
maxMs: z.number().int().nonnegative().optional(),
});
const normalizeAllowFrom = (values?: Array<string | number>): string[] =>
(values ?? []).map((v) => String(v).trim()).filter(Boolean);
@@ -775,6 +783,7 @@ const AgentEntrySchema = z.object({
workspace: z.string().optional(),
agentDir: z.string().optional(),
model: z.string().optional(),
humanDelay: HumanDelaySchema.optional(),
identity: IdentitySchema,
groupChat: GroupChatSchema,
subagents: z
@@ -1043,6 +1052,7 @@ const AgentDefaultsSchema = z
})
.optional(),
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
humanDelay: HumanDelaySchema.optional(),
timeoutSeconds: z.number().int().positive().optional(),
mediaMaxMb: z.number().positive().optional(),
typingIntervalSeconds: z.number().int().positive().optional(),
@@ -1089,7 +1099,6 @@ const AgentDefaultsSchema = z
.optional(),
})
.optional();
export const ClawdbotSchema = z
.object({
env: z