Skip to main content
This page walks through writing a one-shot routine and a continuous one, then using a routine from an agent. Before you start: Condor is installed and connected to a Hummingbot API server. You can open the Routines page or use /routines in Telegram.

What a routine needs

Telegram-only hooks (handle_callback, handle_message, MESSAGE_STATES, cleanup) are listed in the overview.

1. Choose the folder

All paths are relative to the folder you installed Condor into. Create the folder if it doesn’t exist. File names must be valid Python module names, such as momentum_scanner.py. Files that start with _ are skipped in agent and shared folders.

2. Write the routine

This routine measures momentum and volume on recent candles for a few pairs. It returns a RoutineResult, so the Workspace shows a table and Telegram shows the one-line summary.
A few things to know about the API client:
  • get_candles takes max_records, not limit. The server returns a list of candles, each with timestamp, open, high, low, close, volume and quote_asset_volume.
  • get_prices returns {"connector": ..., "prices": {"BTC-USDT": 81714.0, ...}, "timestamp": ...}. Read the prices from result["prices"].

3. Test it

Condor picks up the file without a restart. Then run it from any of these:
  • Workspace: open Routines, select momentum scanner, open Config to change settings, and click Run. Switch to Output to see the table.
  • Telegram: /routines → ⚡ Momentum Scanner → ▶️ Run. Send key=value lines, such as lookback=48, to change the config first. Telegram lists only the general and shared routines, so a routine in an agent’s folder doesn’t appear there.
  • Chat: ask Condor “run momentum_scanner with interval=1h”.
If the routine doesn’t appear, the file failed to load. Check Condor’s log for Failed to load routine or Failed to load agent routine. In Telegram, 🔄 Reload retries files that failed before.
Condor refuses to load a routine whose Config defaults or descriptions look like a credential, such as an API key or a password. Read secrets inside run() from the environment instead.

4. Use it from an agent

If the routine is in the agent’s own routines/ folder or in _shared/routines/, the agent can run it. When the agent runs a loop, its prompt lists the routine and tells it to call:
Name the routine in your loop.md so the agent knows when to use it:
A blocking run waits up to 120 seconds. A longer run keeps going in the background, and the agent reads the result later with action="get_instance". A Dry Run refuses routine runs, so test the routine on its own first. See MCP Tools for the agent tool list and Architecture for how loops work.
A routine that agents run has no Telegram chat behind it. Don’t rely on context.bot.send_message to deliver results. Return a RoutineResult or save a report instead.

Continuous routines

A continuous routine sets CONTINUOUS = True and loops until you stop it. Condor stops it by cancelling the task, so catch asyncio.CancelledError and return a summary. This one checks a price every few seconds and rewrites a single live report each time:
Start it with Run on the Routines page or ▶️ Start in Telegram. Stop it from the Runs list on the Routines page, or with ⏹ Stop All in Telegram. Continuous routines can’t be scheduled.

Let Condor write it

You can describe the routine in the chat instead:
Condor writes the file with manage_routines(action="create_routine"), checks that it loads, and runs it to test it. It saves to .condor/agents/condor/routines/ unless you ask for a shared routine, which goes to .condor/agents/_shared/routines/. An agent asked to write a routine saves it to its own routines/ folder.

Best practices

The same config and the same market data should give the same result. Put judgment in the agent’s skills and loop instructions, not in the routine.
Return a short message such as "No server available" when something expected is missing. An exception marks the run as failed and the Workspace shows the error.
The Config docstring and each Field(description=...) are what you, Condor and agents read to decide how to run the routine.
A routine runs with the full API client. Nothing stops it from placing orders or deploying bots, so keep trading actions in the agent, where the risk engine checks them.
Catch asyncio.CancelledError around the loop and return a summary.