Implement training-to-skill pipeline for agent knowledge persistence
Add learning capture and skill update mechanism to AITBC training system: Phase 1 - Learning Capture Function: - Add capture_learnings() function to master_training_launcher.sh - Reads learnings JSON from stage scripts - Validates JSON structure - Calls hermes-tools skill-manage to update agent skills - Stage 1 creates skill, subsequent stages update it - Falls back to JSON-only if hermes-tools unavailable Phase 2 - Optional Skill Update Flag: - Add --with-skill-update CLI flag - Set ENABLE_SKILL_UPDATE global variable - Support flag combination with --stage and --complete - Default behavior: save learnings JSON without skill update Phase 3 - Integration: - Call capture_learnings() after certificate generation - Pass ENABLE_SKILL_UPDATE to control skill update behavior - Integrated into run_stage() function Phase 4 - Helper Function: - Add output_stage_learnings() to training_lib.sh - Accepts stage number, name, commands, pitfalls, key_paths, concepts - Creates structured JSON learnings file - Saves to .training_state/learnings_stageN.json Phase 5 - Stage Script Learning Output: - Add learning output to all stage scripts (0-9) - Each stage defines stage-specific learnings - Format: commands, pitfalls, key_paths, concepts - Called at successful stage completion This enables new agents on new AITBC nodes to automatically persist training knowledge via the hermes-tools skill management system.
This commit is contained in:
@@ -33,6 +33,9 @@ PROGRESS_FILE="$SCRIPT_DIR/.training_progress"
|
||||
STATE_DIR="$SCRIPT_DIR/.training_state"
|
||||
CERT_DIR="$STATE_DIR/certificates"
|
||||
|
||||
# Skill update flag (default: disabled)
|
||||
ENABLE_SKILL_UPDATE="${ENABLE_SKILL_UPDATE:-false}"
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee "$CURRENT_LOG"
|
||||
@@ -202,6 +205,10 @@ run_stage() {
|
||||
generate_certificate $stage_num
|
||||
display_badge $stage_num
|
||||
|
||||
# Capture learnings for skill update
|
||||
local stage_name=$(get_stage_name $stage_num)
|
||||
capture_learnings $stage_num "$stage_name" "$ENABLE_SKILL_UPDATE"
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Stage $stage_num failed"
|
||||
@@ -353,6 +360,57 @@ display_badge() {
|
||||
echo
|
||||
}
|
||||
|
||||
# Capture learnings from completed stage for skill update
|
||||
capture_learnings() {
|
||||
local stage_num=$1
|
||||
local stage_name=$2
|
||||
local enable_skill_update=$3
|
||||
local learnings_file="$STATE_DIR/learnings_stage${stage_num}.json"
|
||||
|
||||
print_status "Capturing learnings from Stage $stage_num..."
|
||||
|
||||
# Check if learnings file exists (generated by stage script)
|
||||
if [ ! -f "$learnings_file" ]; then
|
||||
print_warning "No learnings file found for Stage $stage_num at $learnings_file"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Validate learnings JSON structure
|
||||
if ! python3 -c "import json; json.load(open('$learnings_file'))" 2>/dev/null; then
|
||||
print_error "Learnings file is not valid JSON: $learnings_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_success "Learnings loaded from $learnings_file"
|
||||
|
||||
# Trigger skill update if enabled and hermes-tools is available
|
||||
if [ "$enable_skill_update" = "true" ]; then
|
||||
if command -v hermes-tools &> /dev/null; then
|
||||
print_status "Updating AITBC skill with new learnings..."
|
||||
|
||||
# Stage 1 creates skill, subsequent stages update it
|
||||
local skill_action="update"
|
||||
if [ "$stage_num" -eq 1 ]; then
|
||||
skill_action="create"
|
||||
print_status "Creating AITBC skill (Stage 1)..."
|
||||
fi
|
||||
|
||||
# Call hermes-tools to update skill
|
||||
if hermes-tools skill-manage --skill aitbc-training --action "$skill_action" --update-from-file "$learnings_file" 2>&1; then
|
||||
print_success "AITBC skill $skill_action successful"
|
||||
else
|
||||
print_warning "Skill update failed - learnings saved for manual processing"
|
||||
fi
|
||||
else
|
||||
print_warning "hermes-tools not available - learnings saved for manual skill update"
|
||||
fi
|
||||
else
|
||||
print_status "Skill update disabled (--with-skill-update not set)"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# View certificates
|
||||
view_certificates() {
|
||||
print_header "Stage Completion Certificates"
|
||||
@@ -1020,6 +1078,32 @@ case "${1:-}" in
|
||||
--playground)
|
||||
show_playground_menu
|
||||
;;
|
||||
--with-skill-update)
|
||||
ENABLE_SKILL_UPDATE=true
|
||||
# Shift and continue to next argument
|
||||
shift
|
||||
case "${1:-}" in
|
||||
--stage)
|
||||
if [[ "$2" =~ ^[0-9]$ ]]; then
|
||||
run_stage "$2"
|
||||
else
|
||||
echo "Usage: $0 --with-skill-update --stage [0-9]"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--complete)
|
||||
run_complete_training
|
||||
;;
|
||||
"")
|
||||
main
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Use --help for usage information"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
--help|-h)
|
||||
echo "hermes AITBC Mastery Training Launcher"
|
||||
echo
|
||||
@@ -1031,6 +1115,7 @@ case "${1:-}" in
|
||||
echo " --stage N Run specific stage (0-9)"
|
||||
echo " --complete Run complete training program"
|
||||
echo " --playground Enter training playground mode"
|
||||
echo " --with-skill-update Enable skill update via hermes-tools"
|
||||
echo " --help, -h Show this help message"
|
||||
echo
|
||||
echo "Without arguments, starts interactive menu"
|
||||
|
||||
@@ -56,6 +56,14 @@ main() {
|
||||
|
||||
if execute_stage_from_json; then
|
||||
print_success "$TRAINING_STAGE completed"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 0 "Environment Setup" \
|
||||
"python3 -m aitbc.training_setup.cli setup|./aitbc-cli blockchain genesis|systemctl status aitbc-blockchain-node.service" \
|
||||
"Genesis password location: /var/lib/aitbc/keystore/.genesis_password|Blockchain RPC on port 8006|Environment variables in /etc/aitbc/.env" \
|
||||
"/var/lib/aitbc/keystore/.genesis_password|/etc/aitbc/.env|/etc/aitbc/node.env" \
|
||||
"Genesis block initialization|Environment setup|Service management"
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "$TRAINING_STAGE failed"
|
||||
|
||||
@@ -278,6 +278,13 @@ main() {
|
||||
print_header "$TRAINING_STAGE COMPLETED SUCCESSFULLY"
|
||||
log_success "$TRAINING_STAGE completed with validation"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 1 "Foundation" \
|
||||
"./aitbc-cli --version|./aitbc-cli wallet create <wallet> <password>|./aitbc-cli wallet balance <wallet>|./aitbc-cli wallet send <from> <to> <amount> <password>|./aitbc-cli service --status|./aitbc-cli service --health" \
|
||||
"fund_accounts.sh --force flag not supported|Use genesis password from /var/lib/aitbc/keystore/.genesis_password|Genesis wallet: ait175406af70445617b0cd7eb8ff384d81b15c26b45" \
|
||||
"/var/lib/aitbc/keystore/.genesis_password|/opt/aitbc/scripts/training/.training_state/certificates|/opt/aitbc/scripts/training/.training_progress" \
|
||||
"Wallet creation|Transaction sending|Balance checking|Service health monitoring"
|
||||
|
||||
echo
|
||||
echo -e "${GREEN}Next Steps:${NC}"
|
||||
echo "1. Review the log file: $CURRENT_LOG"
|
||||
|
||||
@@ -247,6 +247,14 @@ main() {
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}$TRAINING_STAGE COMPLETED${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 2 "Operations Mastery" \
|
||||
"./aitbc-cli wallet export <wallet>|./aitbc-cli blockchain block <height>|./aitbc-cli agent message <to> <message>|./aitbc-cli agent messages|./aitbc-cli network sync" \
|
||||
"Contract commands not yet implemented (--list, --deploy)|Agent message format validation|Block height queries" \
|
||||
"/opt/aitbc/scripts/training/.training_state|/var/log/aitbc" \
|
||||
"Wallet export|Block inspection|Agent messaging|Network synchronization"
|
||||
|
||||
echo
|
||||
echo -e "${BLUE}Next Steps:${NC}"
|
||||
echo "1. Review the log file: $LOG_FILE"
|
||||
|
||||
@@ -382,6 +382,14 @@ main() {
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}$TRAINING_STAGE COMPLETED SUCCESSFULLY${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 3 "AI Operations" \
|
||||
"./aitbc-cli ai-ops submit <model> <prompt>|./aitbc-cli ai-ops status <job_id>|curl http://localhost:9001/tasks/submit" \
|
||||
"Agent Coordinator on port 9001|Task submission format|Job status polling" \
|
||||
"/var/lib/aitbc/keystore|/opt/aitbc/ai-service" \
|
||||
"AI job submission|Task management|Agent Coordinator integration"
|
||||
|
||||
echo
|
||||
echo -e "${BLUE}Next Steps:${NC}"
|
||||
echo "1. Review the log file: $LOG_FILE"
|
||||
|
||||
@@ -309,6 +309,14 @@ main() {
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}$TRAINING_STAGE COMPLETED SUCCESSFULLY${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 4 "Marketplace & Economics" \
|
||||
"./aitbc-cli market-list|./aitbc-cli marketplace --list" \
|
||||
"Marketplace API endpoints|Asset listing format|Currency fields validation" \
|
||||
"/opt/aitbc/apps/marketplace" \
|
||||
"Marketplace operations|Asset listing|Market economics"
|
||||
|
||||
echo
|
||||
echo -e "${BLUE}Next Steps:${NC}"
|
||||
echo "1. Review the log file: $LOG_FILE"
|
||||
|
||||
@@ -460,6 +460,14 @@ main() {
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}$TRAINING_STAGE COMPLETED SUCCESSFULLY${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 5 "Expert Operations" \
|
||||
"curl http://localhost:9001/health|./aitbc-cli agent --status" \
|
||||
"Expert automation workflows|Health check endpoints|Agent status monitoring" \
|
||||
"/opt/aitbc/apps/agent-coordinator" \
|
||||
"Expert automation|Agent health monitoring|Advanced operations"
|
||||
|
||||
echo
|
||||
echo -e "${BLUE}🎓 TRAINING COMPLETION SUMMARY:${NC}"
|
||||
echo "✅ All 5 training stages completed"
|
||||
|
||||
@@ -331,6 +331,13 @@ main() {
|
||||
|
||||
log "$TRAINING_STAGE completed successfully"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 6 "Agent Identity SDK" \
|
||||
"./aitbc-cli agent identity create|./aitbc-cli agent identity list" \
|
||||
"Agent Identity SDK integration|Identity verification|SDK configuration" \
|
||||
"/opt/aitbc/apps/coordinator-api|/opt/aitbc/aitbc-sdk" \
|
||||
"Agent Identity SDK|Identity management|SDK usage"
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "$TRAINING_STAGE COMPLETED SUCCESSFULLY"
|
||||
|
||||
@@ -365,6 +365,13 @@ main() {
|
||||
|
||||
log "$TRAINING_STAGE completed successfully"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 7 "Cross-Node Training" \
|
||||
"./aitbc-cli blockchain sync|./aitbc-cli network peers" \
|
||||
"Cross-node communication|Peer discovery|Sync status monitoring" \
|
||||
"/etc/aitbc/.env|/etc/aitbc/node.env" \
|
||||
"Cross-node training|P2P networking|Multi-node operations"
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "$TRAINING_STAGE COMPLETED SUCCESSFULLY"
|
||||
|
||||
@@ -56,6 +56,14 @@ main() {
|
||||
|
||||
if execute_stage_from_json; then
|
||||
print_success "$TRAINING_STAGE completed"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 8 "Advanced Agent Specialization" \
|
||||
"./aitbc-cli bounty create|./aitbc-cli portfolio manage|./aitbc-cli knowledge-graph list" \
|
||||
"Bounty system management|Portfolio strategies|Knowledge graph marketing" \
|
||||
"/opt/aitbc/apps/blockchain-node" \
|
||||
"Advanced agent specialization|Bounty systems|Portfolio management"
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "$TRAINING_STAGE failed"
|
||||
|
||||
@@ -56,6 +56,14 @@ main() {
|
||||
|
||||
if execute_stage_from_json; then
|
||||
print_success "$TRAINING_STAGE completed"
|
||||
|
||||
# Output learnings for skill update
|
||||
output_stage_learnings 9 "Multi-Chain Architecture" \
|
||||
"./aitbc-cli cross-chain send|./aitbc-cli multi-chain deploy" \
|
||||
"Cross-chain transaction format|Multi-chain deployment|Interoperability" \
|
||||
"/opt/aitbc/apps/blockchain-node" \
|
||||
"Multi-chain architecture|Cross-chain operations|Interoperability"
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "$TRAINING_STAGE failed"
|
||||
|
||||
@@ -483,3 +483,54 @@ cli_cmd_node() {
|
||||
# Use eval to properly parse command string with multiple arguments
|
||||
NODE_URL="$node_url" eval "$CLI_PATH $*" 2>/dev/null
|
||||
}
|
||||
|
||||
# Output stage learnings for skill update
|
||||
output_stage_learnings() {
|
||||
local stage_num=$1
|
||||
local stage_name=$2
|
||||
shift 2
|
||||
|
||||
local commands=()
|
||||
local pitfalls=()
|
||||
local key_paths=()
|
||||
local concepts=()
|
||||
|
||||
# Parse arrays from arguments
|
||||
# Format: output_stage_learnings stage_num stage_name "cmd1|cmd2" "pitfall1|pitfall2" "path1|path2" "concept1|concept2"
|
||||
|
||||
if [ $# -ge 1 ]; then
|
||||
IFS='|' read -ra commands <<< "$1"
|
||||
fi
|
||||
|
||||
if [ $# -ge 2 ]; then
|
||||
IFS='|' read -ra pitfalls <<< "$2"
|
||||
fi
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
IFS='|' read -ra key_paths <<< "$3"
|
||||
fi
|
||||
|
||||
if [ $# -ge 4 ]; then
|
||||
IFS='|' read -ra concepts <<< "$4"
|
||||
fi
|
||||
|
||||
local state_dir="${SCRIPT_DIR}/.training_state"
|
||||
local learnings_file="$state_dir/learnings_stage${stage_num}.json"
|
||||
|
||||
mkdir -p "$state_dir"
|
||||
|
||||
# Create structured learnings JSON
|
||||
cat > "$learnings_file" <<EOF
|
||||
{
|
||||
"stage": $stage_num,
|
||||
"stage_name": "$stage_name",
|
||||
"commands": $(printf '%s\n' "${commands[@]}" | jq -R . | jq -s .),
|
||||
"pitfalls": $(printf '%s\n' "${pitfalls[@]}" | jq -R . | jq -s .),
|
||||
"key_paths": $(printf '%s\n' "${key_paths[@]}" | jq -R . | jq -s .),
|
||||
"concepts": $(printf '%s\n' "${concepts[@]}" | jq -R . | jq -s .),
|
||||
"timestamp": "$(date -Iseconds)"
|
||||
}
|
||||
EOF
|
||||
|
||||
log_info "Learnings saved to $learnings_file"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user