hailo-apps / rules
Cursor rule506 starsChanged 7 months agoMITView on GitHub
Build a complete agent app with LLM reasoning + tool execution on Hailo-10H.
We split this hl-build-agent-app.mdc into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Create the app directory:
- Very specific: line 48
Create app.yaml with type: gen_ai and run.sh wrapper.
- Very specific: line 49
Do NOT register in defines.py or resources_config.yaml.
- Very specific: line 149
Parsing: Use tool_parsing utilities to extract tool calls from LLM output
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: "Build a complete agent app with LLM reasoning + tool execution on Hailo-10H."
alwaysApply: false
---
# Skill: Build Agent Application with Tool Calling
Build a complete agent app with LLM reasoning + tool execution on Hailo-10H.
## When This Skill Is Loaded
- User wants an **LLM agent** that can **call tools / functions**
- User mentions: agent, tools, function calling, actions, execute
- User needs an AI that can **do things** (not just chat)
## Reference Implementation
Study `hailo_apps/python/gen_ai_apps/agent_tools_example/` — the canonical agent app:
- `agent_tools_example.py` — Main agent loop
- `tools/` — Tool implementations (subclass `BaseTool`)
- `config.yaml` — Tool configuration
Also study the agent utilities:
- `gen_ai_utils/llm_utils/tool_parsing.py` — Parse LLM output for tool calls
- `gen_ai_utils/llm_utils/tool_execution.py` — `BaseTool`, `ToolResult`
- `gen_ai_utils/llm_utils/tool_discovery.py` — Auto-discover tools from directory
## Build Process
### Step 1: Create App Directory
Create the app directory:
```
hailo_apps/python/<type>/<app_name>/
├── app.yaml # App manifest (type: gen_ai)
├── run.sh # Launch wrapper
├── __init__.py
├── <app_name>.py # Main agent loop
├── tools/
│ ├── __init__.py
│ ├── config.yaml # Tool metadata
│ ├── my_tool_1.py # Implements BaseTool
│ └── my_tool_2.py # Implements BaseTool
└── README.md # Usage documentation (REQUIRED — never skip)
```
Create `app.yaml` with `type: gen_ai` and `run.sh` wrapper.
Do NOT register in `defines.py` or `resources_config.yaml`.
### Step 2: Build a Tool
Each tool implements the `BaseTool` interface:
```python
from hailo_apps.python.gen_ai_apps.agent_tools_example.tools.base import BaseTool, ToolResult
class WeatherTool(BaseTool):
@property
def name(self) -> str:
return "get_weather"
@property
def description(self) -> str:
return "Get current weather for a city"
@property
def schema(self) -> dict:
return {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name (e.g., 'Tel Aviv')"
}
},
"required": ["city"]
}
def run(self, **kwargs) -> ToolResult:
city = kwargs["city"]
# Actual implementation here
return ToolResult(
success=True,
data={"city": city, "temperature": 25, "condition": "Sunny"}
)
```
### Step 4: Build Tool Config
```yaml
# tools/config.yaml
version: "1.0"
tool_name: "my_agent"
persona: "You are a helpful assistant with access to tools."
capabilities:
- "Look up weather information"
- "Perform calculations"
few_shot_examples:
- user: "What's the weather in Tel Aviv?"
assistant: "I'll check the weather for you."
tool_call: '{"name": "get_weather", "arguments": {"city": "Tel Aviv"}}'
```
### Step 5: Build Main App
```python
import signal
import argparse
from hailo_apps.python.core.common.hailo_logger import get_logger
logger = get_logger(__name__)
APP_NAME = "my_agent_app"
def main():
parser = argparse.ArgumentParser(description="My Agent App")
parser.add_argument("--debug", action="store_true", help="Show tool calls")
parser.add_argument("--multi-turn", action="store_true", help="Enable multi-turn context")
parser.add_argument("--voice", action="store_true", help="Enable voice input")
parser.add_argument("--no-tts", action="store_true", help="Disable TTS")
args = parser.parse_args()
signal.signal(signal.SIGINT, lambda s, f: sys.exit(0))
# Initialize agent (uses AgentApp or custom loop)
# Tool discovery from tools/ directory
# Main loop: user input → LLM reasoning → tool parsing → execution → response
if __name__ == "__main__":
main()
```
### Step 6: Validate
```bash
python3 .hailo/scripts/validate_app.py hailo_apps/python/gen_ai_apps/my_agent_app --smoke-test
```
## Critical Conventions
1. **Tool interface**: Implement `BaseTool` with `name`, `description`, `schema`, `run()`
2. **Return**: `ToolResult(success=bool, data=dict)`
3. **Discovery**: Tools auto-discovered from `tools/` directory
4. **Config**: YAML with `persona`, `capabilities`, `few_shot_examples`
5. **JSON Schema**: Each tool's `schema` property returns valid JSON Schema
6. **Parsing**: Use `tool_parsing` utilities to extract tool calls from LLM output
7. **Context**: `context_manager` for multi-turn, `StateManager` for persistence
8. **Logging**: `get_logger(__name__)`
## Agent Reasoning Loop
```
User Input
│
▼
LLM generates response
│
├── Contains tool call? → Parse → Execute tool → Feed result back to LLM
│ │
│ ▼
│ LLM generates final response
│
└── No tool call? → Direct response to user
```
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository65 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/core-framework.mdcCursor rule
- .cursor/rules/gen-ai-apps.mdcCursor rule
- .cursor/rules/hailo-global.mdcCursor rule
- .cursor/rules/hl-build-llm-app.mdcCursor rule
- .cursor/rules/hl-build-pipeline-app.mdcCursor rule
- .cursor/rules/hl-build-standalone-app.mdcCursor rule
- .cursor/rules/hl-build-vlm-app.mdcCursor rule
- .cursor/rules/hl-build-voice-app.mdcCursor rule
- .cursor/rules/hl-camera.mdcCursor rule
- .cursor/rules/hl-event-detection.mdcCursor rule
- .cursor/rules/hl-model-management.mdcCursor rule
- .cursor/rules/hl-monitoring.mdcCursor rule
- .cursor/rules/hl-plan-and-execute.mdcCursor rule
- .cursor/rules/hl-validate.mdcCursor rule
- .cursor/rules/inst-agent-protocols.mdcCursor rule
- .cursor/rules/inst-architecture.mdcCursor rule
- .cursor/rules/inst-coding-standards.mdcCursor rule
- .cursor/rules/inst-gen-ai-development.mdcCursor rule
- .cursor/rules/inst-gstreamer-pipelines.mdcCursor rule
- .cursor/rules/inst-orchestration.mdcCursor rule
- .cursor/rules/inst-testing-patterns.mdcCursor rule
- .cursor/rules/memory-camera_and_display.mdcCursor rule
- .cursor/rules/memory-common_pitfalls.mdcCursor rule
- .cursor/rules/memory-gen_ai_patterns.mdcCursor rule
- .cursor/rules/memory-hailo_platform_api.mdcCursor rule
- .cursor/rules/memory-MEMORY.mdcCursor rule
- .cursor/rules/memory-pipeline_optimization.mdcCursor rule
- .cursor/rules/pipeline-apps.mdcCursor rule
- .cursor/rules/prompt-new-agent-tool.mdcCursor rule
- .cursor/rules/prompt-new-llm-app.mdcCursor rule
- .cursor/rules/prompt-new-pipeline-app.mdcCursor rule
- .cursor/rules/prompt-new-pose-game.mdcCursor rule
- .cursor/rules/prompt-new-standalone-app.mdcCursor rule
- .cursor/rules/prompt-new-vlm-variant.mdcCursor rule
- .cursor/rules/prompt-new-voice-app.mdcCursor rule
- .cursor/rules/prompt-orchestrated-build.mdcCursor rule
- .cursor/rules/standalone-apps.mdcCursor rule
- .cursor/rules/tests.mdcCursor rule
- .cursor/rules/toolset-core-framework-api.mdcCursor rule
- .cursor/rules/toolset-gen-ai-utilities.mdcCursor rule
- .cursor/rules/toolset-gstreamer-elements.mdcCursor rule
- .cursor/rules/toolset-hailort-api.mdcCursor rule
- .cursor/rules/toolset-pose-keypoints.mdcCursor rule
- .cursor/rules/toolset-vlm-backend-api.mdcCursor rule
- .cursor/rules/toolset-yolo-coco-classes.mdcCursor rule
- hl-build-agent-appSkill
- hl-build-llm-appSkill
- hl-build-pipeline-appSkill
- hl-build-standalone-appSkill
- hl-build-vlm-appSkill
- hl-build-voice-appSkill
- hl-cameraSkill
- hl-event-detectionSkill
- hl-model-managementSkill
- hl-monitoringSkill
- hl-plan-and-executeSkill
- hl-validateSkill
- hl-build-agent-appSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

