HiveLang basics
Learn the few building blocks needed to define an agent. Each section explains the idea first, then shows the code.
The mental model
A HiveLang file answers three questions:
- What is this agent responsible for? Put that in
instructions. - What is it allowed to do? List those tools in
capabilities. - When should it act? Define that in an
onevent block.
1. Define an agent
Every file starts with a named bot block. Instructions are ordinary text, so non-developers can review the agent’s job without learning programming syntax.
bot Greeter {
instructions {
Welcome the user and answer in one short paragraph.
}
on user.message {
respond
}
}2. Store values
Assign a value with =. Variable names do not use a dollar-sign prefix.
name = "Ada"
greeting = f"Hello {name}"
say greetingf"Hello {name}" when inserting a value into text. A plain string prints the braces literally.3. Give the agent a tool
Declaring a capability is a permission boundary. The agent cannot call a tool merely because it knows the tool exists.
capabilities {
web.search
}
on user.message {
results = call web.search with { query: input }
say f"Here is what I found: {results.summary}"
}Connect any account required by the capability under Dashboard → Integrations. Do not place credentials inside HiveLang.
4. Add a decision
Use if and else when the next action depends on data.
if input contains "refund" {
say "I will help with the refund process."
} else {
respond
}Complete example
This agent combines instructions, a capability, a tool call, a variable, and a conditional.
bot ResearchAssistant {
description: "Researches a topic and returns a short summary"
capabilities {
web.search
}
instructions {
Be concise. Use search results when they are available.
Never invent a source.
}
on user.message {
results = call web.search with { query: input }
if results.length > 0 {
say f"I found {results.length} results. {results.summary}"
} else {
say "I could not find a reliable result."
}
}
}Common mistakes
$name = valuename = valuetool.method(input)call tool.method with { key: input }"Hello {name}"f"Hello {name}"input.contains("help")input contains "help"