Advanced 4 - Behavior engine
System prompts are guidelines. They give the model intent but they do not enforce anything. When the model decides to edit a file without reading it first, the prompt did not stop it; only the model's discipline did.
The behavior engine is the runtime layer that turns guidelines into rules. It watches every tool call as it happens, evaluates a list of declarative rules against the call's parameters and the session state, and injects corrections back into the model's context when a rule fires. The model sees the warning on the next turn and (usually) corrects course.
Six built-in profiles ship preinstalled (dev, coding,
research, data, creative, assistant). Each is a curated
set of rules tuned to a working style. You can also write custom
rules.
What the rules look like
A rule is a name plus a trigger. Some rules from the coding
profile:
| Rule | Triggers when… | Effect |
|---|---|---|
read_before_edit | The agent calls Edit on a file it has not Read | Warns + injects "call Read first" |
verify_after_edit | The agent calls Edit and then doesn't Read again | Reminds the agent to verify |
test_after_changes | N+ edits without a test run | Reminds to run tests |
no_bash_for_files | The agent uses Bash("cat file") instead of Read | Warns + suggests the right tool |
confirm_destructive | The agent attempts rm -rf, DROP TABLE, etc. | Blocks until the user approves |
delegate_complex | One specialist tries to do a 5+ tool task alone | Reminds about Agent() dispatch |
The full list is in the behavior engine reference.
The YAML
Save this as behavior-bot.yaml. The agent has free filesystem
access; the behaviour engine is the only thing keeping it tidy.
app:
app_id: behavior-bot
name: Behavior Bot
version: "1.0"
runtime:
mode: conversation
workdir_mode: auto
max_turns: 6
timeout: 90
agents:
- id: main
role: assistant
brain:
provider: deepseek
model: deepseek-chat
backend: openai_compat
credential:
ref: deepseek_main
scope: per_user
provider: deepseek
config:
api_key: "{{env.DEEPSEEK_API_KEY}}"
base_url: https://api.deepseek.com/v1
temperature: 0
max_tokens: 400
system_prompt: |
You are a code-editing assistant. Use Read, Edit, and Bash.
Reply concisely.
tools:
modules:
filesystem: {}
shell: {}
memory: {}
capabilities:
default_policy: auto
security:
behavior:
profile: coding
classify_turns: false
The new piece is security.behavior.profile: coding. That single
line activates 14 rules tuned to code-editing workflows.
classify_turns: false keeps the optional classifier brain
off (covered below).
Setup
Create a workspace with one tiny Python file:
mkdir -p ./behavior-ws
printf 'def add(a, b):\n return a + b\n' \
> ./behavior-ws/code.ts
Now ask the agent to edit without reading, on purpose, to exercise the engine.