77#
88# Usage:
99# ./run_agent_test.sh <tutorial_path> # Run single tutorial test
10+ # ./run_agent_test.sh --build-cli <tutorial_path> # Build CLI from source and run test
1011# ./run_agent_test.sh --view-logs <tutorial_path> # View logs for specific tutorial
1112# ./run_agent_test.sh --view-logs # View most recent agent logs
1213#
@@ -28,10 +29,13 @@ AGENTEX_SERVER_PORT=5003
2829# Parse arguments
2930TUTORIAL_PATH=" "
3031VIEW_LOGS=false
32+ BUILD_CLI=false
3133
3234for arg in " $@ " ; do
3335 if [[ " $arg " == " --view-logs" ]]; then
3436 VIEW_LOGS=true
37+ elif [[ " $arg " == " --build-cli" ]]; then
38+ BUILD_CLI=true
3539 else
3640 TUTORIAL_PATH=" $arg "
3741 fi
@@ -105,7 +109,8 @@ start_agent() {
105109 cd " $tutorial_path " || return 1
106110
107111 # Start the agent in background and capture PID
108- uv run agentex agents run --manifest manifest.yaml > " $logfile " 2>&1 &
112+ local agentex_cmd=$( get_agentex_command)
113+ $agentex_cmd agents run --manifest manifest.yaml > " $logfile " 2>&1 &
109114 local pid=$!
110115
111116 # Return to original directory
@@ -275,6 +280,58 @@ execute_tutorial_test() {
275280 fi
276281}
277282
283+ # Function to build CLI from source
284+ build_cli () {
285+ echo -e " ${YELLOW} 🔨 Building CLI from source...${NC} "
286+
287+ # Navigate to the repo root (two levels up from examples/tutorials)
288+ local repo_root=" ../../"
289+ local original_dir=" $PWD "
290+
291+ cd " $repo_root " || {
292+ echo -e " ${RED} ❌ Failed to navigate to repo root${NC} "
293+ return 1
294+ }
295+
296+ # Check if rye is available
297+ if ! command -v rye & > /dev/null; then
298+ echo -e " ${RED} ❌ rye is required to build the CLI${NC} "
299+ echo " Please install rye: curl -sSf https://rye.astral.sh/get | bash"
300+ cd " $original_dir "
301+ return 1
302+ fi
303+
304+ # Build the CLI
305+ echo -e " ${YELLOW} Running rye sync --all-features...${NC} "
306+ if ! rye sync --all-features; then
307+ echo -e " ${RED} ❌ Failed to sync dependencies${NC} "
308+ cd " $original_dir "
309+ return 1
310+ fi
311+
312+ echo -e " ${YELLOW} Running rye build...${NC} "
313+ if ! rye build; then
314+ echo -e " ${RED} ❌ Failed to build package${NC} "
315+ cd " $original_dir "
316+ return 1
317+ fi
318+
319+ echo -e " ${GREEN} ✅ CLI built successfully${NC} "
320+ cd " $original_dir "
321+ return 0
322+ }
323+
324+ # Function to get the appropriate agentex command
325+ get_agentex_command () {
326+ if [ " $BUILD_CLI " = true ]; then
327+ # Use the local build via rye run from repo root
328+ echo " ../../rye run agentex"
329+ else
330+ # Use the system-installed version
331+ echo " uv run agentex"
332+ fi
333+ }
334+
278335# Main execution function
279336main () {
280337 # Handle --view-logs flag
@@ -293,11 +350,13 @@ main() {
293350 echo " "
294351 echo " Usage:"
295352 echo " ./run_agent_test.sh <tutorial_path> # Run single tutorial test"
353+ echo " ./run_agent_test.sh --build-cli <tutorial_path> # Build CLI from source and run test"
296354 echo " ./run_agent_test.sh --view-logs <tutorial_path> # View logs for specific tutorial"
297355 echo " ./run_agent_test.sh --view-logs # View most recent agent logs"
298356 echo " "
299- echo " Example :"
357+ echo " Examples :"
300358 echo " ./run_agent_test.sh 00_sync/000_hello_acp"
359+ echo " ./run_agent_test.sh --build-cli 00_sync/000_hello_acp"
301360 exit 1
302361 fi
303362
@@ -311,6 +370,15 @@ main() {
311370
312371 echo " "
313372
373+ # Build CLI if requested
374+ if [ " $BUILD_CLI " = true ]; then
375+ if ! build_cli; then
376+ echo -e " ${RED} ❌ Failed to build CLI from source${NC} "
377+ exit 1
378+ fi
379+ echo " "
380+ fi
381+
314382 # Execute the single tutorial test
315383 if execute_tutorial_test " $TUTORIAL_PATH " ; then
316384 echo " "
0 commit comments