From f958adf53c81d7d89653c0352c6e025bd0c57d71 Mon Sep 17 00:00:00 2001 From: Changyong Gong Date: Mon, 15 Sep 2025 15:19:09 +0800 Subject: [PATCH 1/2] Update triage agent workflow to start orchestration --- .github/workflows/triage-agent.yml | 140 +++++++++++++++++++++++++---- 1 file changed, 121 insertions(+), 19 deletions(-) diff --git a/.github/workflows/triage-agent.yml b/.github/workflows/triage-agent.yml index dc4af07a..f343055b 100644 --- a/.github/workflows/triage-agent.yml +++ b/.github/workflows/triage-agent.yml @@ -49,13 +49,13 @@ jobs: const labelNames = (issue.labels || []).map(label => label.name); core.setOutput('labels', JSON.stringify(labelNames)); - - name: Call Azure Function - id: call_azure_function + - name: Start Triage Orchestration + id: start_orchestration env: PAYLOAD: >- { "authToken": "${{ secrets.GITHUB_TOKEN }}", - "repoId": "microsoft/vscode-java-pack", + "repoId": "chagong/vscode-java-pack", "issueData": { "id": ${{ steps.get_issue.outputs.id }}, "user": ${{ toJson(steps.get_issue.outputs.user) }}, @@ -67,13 +67,14 @@ jobs: } run: | - # Make the HTTP request with improved error handling and timeouts - echo "Making request to triage agent..." + # Start the durable function orchestration + echo "Starting triage orchestration..." + echo "Payload size: $(echo "$PAYLOAD" | wc -c) bytes" - # Add timeout handling and better error detection + # Make the initial request to start orchestration set +e # Don't exit on curl failure - response=$(timeout ${{ vars.TRIAGE_AGENT_TIMEOUT }} curl \ - --max-time 0 \ + response=$(curl \ + --max-time 60 \ --connect-timeout 30 \ --fail-with-body \ --silent \ @@ -82,19 +83,16 @@ jobs: --header "Content-Type: application/json" \ --request POST \ --data "$PAYLOAD" \ - ${{ secrets.TRIAGE_FUNCTION_LINK }} 2>&1) + ${{ secrets.TRIAGE_START_ENDPOINT }} 2>&1) curl_exit_code=$? set -e # Re-enable exit on error - echo "Curl exit code: $curl_exit_code" + echo "Start orchestration curl exit code: $curl_exit_code" - # Check if curl command timed out or failed - if [ $curl_exit_code -eq 124 ]; then - echo "❌ Request timed out after 650 seconds" - exit 1 - elif [ $curl_exit_code -ne 0 ]; then - echo "❌ Curl command failed with exit code: $curl_exit_code" + # Check if curl command failed + if [ $curl_exit_code -ne 0 ]; then + echo "❌ Failed to start orchestration with exit code: $curl_exit_code" echo "Response: $response" exit 1 fi @@ -112,11 +110,115 @@ jobs: exit 1 fi - # Check if the request was successful + # Check if the orchestration started successfully if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then - echo "✅ Azure Function call succeeded" + echo "✅ Triage orchestration started successfully" + echo "Response: $response_body" + + # Extract instance ID from response (assuming JSON response with instanceId field) + instance_id=$(echo "$response_body" | grep -o '"instanceId":"[^"]*"' | cut -d'"' -f4) + if [ -z "$instance_id" ]; then + echo "❌ Failed to extract instance ID from response" + echo "Response body: $response_body" + exit 1 + fi + + echo "Instance ID: $instance_id" + echo "instance_id=$instance_id" >> $GITHUB_OUTPUT else - echo "❌ Azure Function call failed with status code: $http_code" + echo "❌ Failed to start orchestration with status code: $http_code" echo "Response: $response_body" exit 1 fi + + - name: Poll Orchestration Status + id: poll_status + run: | + # Poll the orchestration status until completion + instance_id="${{ steps.start_orchestration.outputs.instance_id }}" + echo "Polling status for instance: $instance_id" + + max_attempts=120 # Maximum number of polling attempts (10 minutes with 5-second intervals) + attempt=0 + + while [ $attempt -lt $max_attempts ]; do + attempt=$((attempt + 1)) + echo "Polling attempt $attempt/$max_attempts..." + + # Make status check request + set +e # Don't exit on curl failure + # Safely replace the {instanceId} placeholder using bash parameter expansion + status_url="${{ secrets.TRIAGE_STATUS_ENDPOINT }}" + status_url="${status_url//\{instanceId\}/$instance_id}" + + response=$(curl \ + --max-time 30 \ + --connect-timeout 15 \ + --fail-with-body \ + --silent \ + --show-error \ + --write-out "HTTPSTATUS:%{http_code}" \ + --request GET \ + "$status_url" 2>&1) + + curl_exit_code=$? + set -e # Re-enable exit on error + + if [ $curl_exit_code -ne 0 ]; then + echo "❌ Status check failed with exit code: $curl_exit_code" + echo "Response: $response" + sleep 5 + continue + fi + + # Extract HTTP status code and response body + http_code=$(echo "$response" | grep -o "HTTPSTATUS:[0-9]*" | cut -d: -f2) + response_body=$(echo "$response" | sed 's/HTTPSTATUS:[0-9]*$//') + + echo "Status check HTTP code: $http_code" + + if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then + echo "Status response: $response_body" + + # Check if orchestration is complete (using runtimeStatus field from actual response schema) + runtime_status=$(echo "$response_body" | grep -o '"runtimeStatus":"[^"]*"' | cut -d'"' -f4) + + if [ "$runtime_status" = "Completed" ] || [ "$runtime_status" = "completed" ]; then + echo "✅ Triage orchestration completed successfully" + # Extract and display output if available + output=$(echo "$response_body" | grep -o '"output":[^,}]*' | cut -d':' -f2-) + if [ "$output" != "null" ] && [ -n "$output" ]; then + echo "Orchestration output: $output" + fi + exit 0 + elif [ "$runtime_status" = "Failed" ] || [ "$runtime_status" = "failed" ]; then + echo "❌ Triage orchestration failed" + echo "Final response: $response_body" + # Extract and display output for error details if available + output=$(echo "$response_body" | grep -o '"output":[^,}]*' | cut -d':' -f2-) + if [ "$output" != "null" ] && [ -n "$output" ]; then + echo "Error details: $output" + fi + exit 1 + elif [ "$runtime_status" = "Running" ] || [ "$runtime_status" = "running" ] || [ "$runtime_status" = "Pending" ] || [ "$runtime_status" = "pending" ]; then + echo "Orchestration status: $runtime_status, waiting..." + # Display last updated time for better monitoring + last_updated=$(echo "$response_body" | grep -o '"lastUpdatedAt":"[^"]*"' | cut -d'"' -f4) + if [ -n "$last_updated" ]; then + echo "Last updated: $last_updated" + fi + sleep 5 + else + echo "Unknown runtime status: $runtime_status, continuing to poll..." + echo "Full response: $response_body" + sleep 5 + fi + else + echo "❌ Status check returned HTTP $http_code" + echo "Response: $response_body" + sleep 5 + fi + done + + echo "❌ Orchestration polling timed out after $max_attempts attempts" + exit 1 From a533f37f7c7a1066f1ecfaae7ae2670cf63ea878 Mon Sep 17 00:00:00 2001 From: Changyong Gong Date: Mon, 15 Sep 2025 15:20:35 +0800 Subject: [PATCH 2/2] Update repoId in triage-agent.yml workflow --- .github/workflows/triage-agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/triage-agent.yml b/.github/workflows/triage-agent.yml index f343055b..195e9b3d 100644 --- a/.github/workflows/triage-agent.yml +++ b/.github/workflows/triage-agent.yml @@ -55,7 +55,7 @@ jobs: PAYLOAD: >- { "authToken": "${{ secrets.GITHUB_TOKEN }}", - "repoId": "chagong/vscode-java-pack", + "repoId": "microsoft/vscode-java-pack", "issueData": { "id": ${{ steps.get_issue.outputs.id }}, "user": ${{ toJson(steps.get_issue.outputs.user) }},