Skip to content

Policies - Safety & Constraints ​

examples/02-policies.halo policies

Define policies, apply to agents with requires Policies restrict agent behavior (block profanity, limit length, etc.)

Open in the playground →

halo
// ============================================================
// STEP 2: Policies - Safety & Constraints
// Learn: Define policies, apply to agents with `requires`
// Policies restrict agent behavior (block profanity, limit length, etc.)
// ============================================================

// Define policies (combine rules with &)
policy NoProfanity : Block(Profanity) & LogViolation()
policy Brevity : MaxWords(50)

// Apply policies to agents with `requires`
agent Greeter [gemini-3-1-pro, temp: 0.7]
  requires NoProfanity, Brevity

pipeline HelloWorld(name: String) -> Result:
  name
    |> Greeter.prompt("Write a warm, one-sentence 'Hello World' greeting for this person.")
    |> System.Print()

curl -fsSL https://halolang.com/install.sh | sh