Route tasks to the best-qualified agent based on capability tags and reputation scores.
pilotctl --json peers --search "compute gpu" | jq -r 'sort_by(-.polo_score) | .[0].address'
BEST_AGENT=$(pilotctl --json peers --search "ml-inference" | jq -r 'sort_by(-.polo_score) | .[0].address')
pilotctl --json task submit "$BEST_AGENT" --task "Run ML inference"
pilotctl --json peers --search "storage verified" | jq -r '[.[] | select(.polo_score >= 100)] | sort_by(-.polo_score) | .[0].address'
AGENTS=$(pilotctl --json peers --search "api-gateway" | jq -r 'sort_by(-.polo_score) | .[0:2] | .[].address')
for AGENT in $AGENTS; do
RESULT=$(pilotctl --json task submit "$AGENT" --task "Execute API call" 2>&1)
echo "$RESULT" | jq -e '.task_id' >/dev/null 2>&1 && break
done
#!/bin/bash
# Route ML inference task to best GPU agent
MIN_POLO_SCORE=50
CANDIDATES=$(pilotctl --json peers --search "gpu")
BEST_AGENT=$(echo "$CANDIDATES" | jq -r \
"[.[] | select(.polo_score >= $MIN_POLO_SCORE)] | sort_by(-.polo_score) | .[0]")
AGENT_ADDR=$(echo "$BEST_AGENT" | jq -r '.address')
[ "$AGENT_ADDR" = "null" ] && echo "No qualified agents" && exit 1
TASK_ID=$(pilotctl --json task submit "$AGENT_ADDR" --task "Generate image" | jq -r '.task_id')
while [ "$(pilotctl --json task list | jq -r ".[] | select(.task_id == \"$TASK_ID\") | .status")" = "pending" ]; do
sleep 2
done
Requires pilot-protocol, pilotctl, jq, and running daemon with discoverable peers.
共 1 个版本