CLI Testing
Query your agent directly from the terminal. This is the fastest way to test during development — no browser needed, fully scriptable, and you see exactly what's happening.
Prerequisites
Install these CLI tools:
# HTTPie (for making requests)
brew install httpie # macOS
apt install httpie # Ubuntu/Debian
# jq (for parsing JSON)
brew install jq # macOS
apt install jq # Ubuntu/Debian
The ask.sh Script
Create this script in your project root:
#!/usr/bin/env bash
set -euo pipefail
# Usage check
if [ -z "${1:-}" ]; then
echo "Usage: $0 \"<query>\" [max_tokens] [role] [analysis_mode]"
echo ""
echo "Examples:"
echo " $0 \"What contacts do we have?\""
echo " $0 \"List all deals\" 4000 admin false"
exit 1
fi
# Config
AUTH_TOKEN=$(< ./.auth_token)
API_URL="http://localhost:5000/agent/query-stream"
# Arguments
QUERY="$1"
MAX_TOKENS="${2:-8000}"
ROLE="${3:-user}"
ANALYSIS_MODE="${4:-false}"
# Temp file for capturing streamed output
TMPFILE="$(mktemp)"
trap 'rm -f "$TMPFILE"' EXIT
echo "🤖 Querying: $QUERY"
echo "---"
# Stream response to stdout AND save to file
http -A bearer -a "$AUTH_TOKEN" \
"$API_URL" \
query="$QUERY" \
max_tokens:="$MAX_TOKENS" \
role="$ROLE" \
analysis_mode:="$ANALYSIS_MODE" \
| tee "$TMPFILE"
# Extract and display final response
FINAL_MSG=$(
awk -v RS= -v ORS="\n\n" '/"type": *"final_response"/ {print}' "$TMPFILE" \
| sed 's/^data: //g' \
| jq -r '.data.response // empty' 2>/dev/null || true
)
echo ""
if [ -n "$FINAL_MSG" ]; then
printf "\033[1;32m✓ Final Response:\033[0m\n%s\n" "$FINAL_MSG"
else
printf "\033[1;33m⚠ No final_response found in stream\033[0m\n"
fi
Setup
# Make executable
chmod +x ask.sh
# Save your auth token (get this from app.daemo.ai)
echo "your-auth-token-here" > .auth_token
Add .auth_token to your .gitignore — never commit tokens!
Usage Examples
Basic Query
./ask.sh "What contacts do we have?"
With Parameters
./ask.sh "List all deals in the pipeline" 8000 admin false
| Parameter | Default | Description |
|---|---|---|
query | (required) | The natural language question |
max_tokens | 8000 | Maximum response tokens |
role | user | User role for RBAC testing |
analysis_mode | false | Enable verbose reasoning |
What You'll See
The script streams Server-Sent Events (SSE) showing exactly what the agent does:
Stream Event Types
| Event | Description |
|---|---|
thinking | Agent is reasoning about the query |
function_call | Agent is calling one of your functions |
function_result | Result returned from your function |
final_response | The complete answer |
error | Something went wrong |
Watch the function_call events to verify the AI is selecting the right functions. If it's choosing wrong, improve your @DaemoFunction descriptions.
Alternative: curl
Prefer curl over HTTPie? Here's a simpler version:
#!/usr/bin/env bash
AUTH_TOKEN=$(< ./.auth_token)
QUERY="$1"
curl -N -X POST "http://localhost:5000/agent/query-stream" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"query\": \"$QUERY\",
\"max_tokens\": 8000,
\"role\": \"user\",
\"analysis_mode\": false
}"
The -N flag disables buffering so you see the stream in real-time.
Role-Based Testing
If your functions implement access control, test with different roles:
# As regular user
./ask.sh "Show me all contacts" 8000 user false
# As admin (may have elevated access)
./ask.sh "Show me all contacts" 8000 admin false
# As specific role
./ask.sh "Show me salary data" 8000 hr_manager false
This helps verify your RBAC logic works correctly.
Building Test Suites
Create automated test scripts:
#!/usr/bin/env bash
set -e
echo "╔══════════════════════════════════════╗"
echo "║ Running Agent Test Suite ║"
echo "╚══════════════════════════════════════╝"
run_test() {
local name="$1"
local query="$2"
echo ""
echo "━━━ Test: $name ━━━"
./ask.sh "$query" 4000 user false
}
run_test "Contact Search" "Find contacts at Acme Corp"
run_test "Deal Pipeline" "How many deals are in each stage?"
run_test "Semantic Search" "What notes mention budget concerns?"
run_test "Edge Case: Empty" "Find contacts with email xyz@nonexistent.com"
echo ""
echo "✅ All tests complete!"
Tips for Effective Testing
1. Test Edge Cases
# Empty results
./ask.sh "Find contacts with email xyz@nonexistent.com"
# Invalid inputs
./ask.sh "Get deal with ID invalid-uuid-here"
# Boundary conditions
./ask.sh "List all contacts" # What if there are 10,000?
2. Test Function Selection
Ask ambiguous questions to verify the AI picks the right function:
# Should use searchContactsByEmail
./ask.sh "Find john@example.com"
# Should use getContactsByCompany
./ask.sh "Who works at Acme Corp?"
# Should use semantic search
./ask.sh "What did we discuss about pricing?"
3. Test Error Handling
# Trigger validation errors
./ask.sh "Delete contact 12345" # Invalid UUID
# Test timeout handling
./ask.sh "Generate a very complex report" # Slow operation