Skip to main content

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.

Fast iteration — test without leaving your IDE
📜Scriptable — automate test suites
🔍Transparent — see every function call in the stream

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:

ask.sh
#!/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
Warning

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
ParameterDefaultDescription
query(required)The natural language question
max_tokens8000Maximum response tokens
roleuserUser role for RBAC testing
analysis_modefalseEnable verbose reasoning

What You'll See

The script streams Server-Sent Events (SSE) showing exactly what the agent does:

Terminal
./ask.sh "How many deals are in each stage?"
🤖 Querying: How many deals are in each stage?
---
data: {"type": "thinking", "data": {"content": "I need to query deals..."}}
data: {"type": "function_call", "data": {"name": "getDealsByStage", ...}}
data: {"type": "function_result", "data": {"result": [...]}}
data: {"type": "final_response", "data": {"response": "Here is the breakdown..."}}
✓ Final Response:
Here is the breakdown of deals by stage:
• Lead Identified: 12 deals
• Meeting Scheduled: 8 deals
• Proposal Sent: 5 deals

Stream Event Types

EventDescription
thinkingAgent is reasoning about the query
function_callAgent is calling one of your functions
function_resultResult returned from your function
final_responseThe complete answer
errorSomething went wrong
Tip

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:

ask-curl.sh
#!/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
}"
Note

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:

test-suite.sh
#!/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

Next Steps