Skip to content
API Blog

Testing

Lobu provides multiple ways to test your agent during development.

Send a prompt and stream the response in your terminal.

Terminal window
# Basic test
npx @lobu/cli@latest chat "Hello, what can you do?"
# Multi-turn conversation
npx @lobu/cli@latest chat "What's on my calendar?" --thread my-test
npx @lobu/cli@latest chat "Cancel the 3pm meeting" --thread my-test
# Target a specific agent (if you have multiple in lobu.toml)
npx @lobu/cli@latest chat "Hello" --agent support
# Dry run (no history persisted)
npx @lobu/cli@latest chat "Test prompt" --dry-run
# Force a fresh session
npx @lobu/cli@latest chat "Start over" --new

This uses API mode — the agent runs and responds directly to your terminal. No platform connection needed.

Route messages through a connected platform to test the full end-to-end flow.

The --user flag routes your message through a platform connection:

Terminal window
# Send as a Telegram user
npx @lobu/cli@latest chat "Hello" --user telegram:12345
# Send to a Slack channel
npx @lobu/cli@latest chat "Hello" --user slack:C0123ABCD
# Send to Discord
npx @lobu/cli@latest chat "Hello" --user discord:987654321

The response appears on the platform and streams to your terminal.

The test-bot.sh script automates platform testing with automatic response polling:

Terminal window
# Auto-detect platform from active connections
./scripts/test-bot.sh "Hello, test message"
# Send multiple messages in sequence
./scripts/test-bot.sh "First question" "Follow-up" "Third message"
# Explicit platform
TEST_PLATFORM=telegram ./scripts/test-bot.sh "Hello"
TEST_PLATFORM=slack ./scripts/test-bot.sh "Hello"

For Telegram, the script sends messages as your real user account using tguser, so the bot sees a real user message:

Terminal window
# Uses the active Telegram bot connection from the gateway
./scripts/test-bot.sh "Hello bot"
# Target a specific bot
TEST_CHANNEL=@mybot ./scripts/test-bot.sh "Hello"

Requirements: tguser installed, TG_API_ID and TG_API_HASH set in .env.

Terminal window
TEST_PLATFORM=slack QA_SLACK_CHANNEL=C0123ABCD ./scripts/test-bot.sh "Hello"

Set SLACK_BOT_TOKEN in .env to enable automatic reply polling.

Terminal window
TEST_PLATFORM=whatsapp TEST_CHANNEL=+1234567890 ./scripts/test-bot.sh "Hello"
VariableDescription
TEST_PLATFORMForce platform: telegram, slack, whatsapp (auto-detected if unset)
TEST_CHANNELChannel/chat ID for the target platform
TEST_TIMEOUTResponse timeout in seconds (default: 120)
TEST_AGENT_IDAgent ID to test (default: test-{platform})
GATEWAY_URLGateway URL (default: http://localhost:8080)

Send messages directly to the gateway HTTP API:

Terminal window
curl -X POST http://localhost:8080/api/v1/agents/{agentId}/messages \
-H "Authorization: Bearer $ADMIN_PASSWORD" \
-H "Content-Type: application/json" \
-d '{
"platform": "api",
"content": "Hello!"
}'

Route through a platform by adding platform-specific fields:

Terminal window
# Through Slack
curl -X POST http://localhost:8080/api/v1/agents/{agentId}/messages \
-H "Authorization: Bearer $ADMIN_PASSWORD" \
-H "Content-Type: application/json" \
-d '{
"platform": "slack",
"content": "Hello!",
"slack": { "channel": "C0123ABCD" }
}'
# Through Telegram
curl -X POST http://localhost:8080/api/v1/agents/{agentId}/messages \
-H "Authorization: Bearer $ADMIN_PASSWORD" \
-H "Content-Type: application/json" \
-d '{
"platform": "telegram",
"content": "Hello!",
"telegram": { "chatId": "12345" }
}'

Browse all available endpoints at /api/docs on your running gateway.

Use named contexts to test against staging or production:

Terminal window
# Add a staging context
npx @lobu/cli@latest context add staging --api-url https://staging.example.com/api/v1
npx @lobu/cli@latest login -c staging
# Chat with the staging agent
npx @lobu/cli@latest chat "Hello" -c staging

If the agent gives stale or incorrect responses, clear the chat history in Redis:

Terminal window
# Find chat history keys
docker compose -f docker/docker-compose.yml exec redis redis-cli KEYS 'chat:history:*'
# Delete a specific conversation
docker compose -f docker/docker-compose.yml exec redis redis-cli DEL 'chat:history:{key}'

For automated quality checks, use the eval command:

Terminal window
npx @lobu/cli@latest eval # run all evals
npx @lobu/cli@latest eval basic-qa # run a specific eval
npx @lobu/cli@latest eval --model claude/sonnet # eval with a specific model
npx @lobu/cli@latest eval --list # list available evals
npx @lobu/cli@latest eval --ci --output results.json # CI mode

Eval files live in the agent directory and define test cases with expected outcomes. Use --ci for non-zero exit codes on failure in CI/CD pipelines.