From 0aadefb28fa61bf5987c037e5bc91085d3376469 Mon Sep 17 00:00:00 2001 From: enxebre Date: Thu, 11 Jun 2026 22:43:10 +0200 Subject: [PATCH 1/2] jira-agent: refresh token before Phase 3 and increase Phase 4 max-turns Phase 3 (address review findings) pushes code to the fork, but its GitHub App token was generated at job start and can expire after 1 hour. When Phases 1-2 run long, Phase 3's push fails with "Invalid username or token". Add a fork token refresh before Phase 3 starts (matching the existing refresh before Phase 4). Also increase Phase 4 max-turns from 15 to 30. When the push encounters pre-push hook failures, 15 turns is not enough to diagnose, fix, and retry before creating the PR. Co-Authored-By: Claude Opus 4.6 --- .../hypershift-jira-agent-process-commands.sh | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh b/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh index 745d5f6e3c386..783d57b344b9e 100755 --- a/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh +++ b/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh @@ -537,6 +537,17 @@ while IFS= read -r line; do REVIEW_FINDINGS=$(cat "${SHARED_DIR}/claude-${ISSUE_KEY}-review-text.txt") fi + # Refresh tokens before Phase 3 since it pushes code. + # Phases 1-2 can exceed the 1-hour GitHub App token lifetime. + echo "Refreshing GitHub App tokens before Phase 3..." + GITHUB_TOKEN_FORK=$(generate_github_token "$INSTALLATION_ID_FORK") + if [ -z "$GITHUB_TOKEN_FORK" ] || [ "$GITHUB_TOKEN_FORK" = "null" ]; then + echo "ERROR: Failed to refresh GitHub App token for fork" + else + git config --global credential.helper "!f() { echo username=x-access-token; echo password=${GITHUB_TOKEN_FORK}; }; f" + echo "Fork token refreshed" + fi + PHASE3_START=$(date +%s) if [ -n "$REVIEW_FINDINGS" ]; then @@ -602,11 +613,10 @@ IMPORTANT: echo "Phase 3 duration: ${PHASE3_DURATION}s" echo "$PHASE3_DURATION" > "${SHARED_DIR}/claude-${ISSUE_KEY}-fix-duration.txt" - # Regenerate GitHub App tokens before push/PR operations. - # Installation tokens expire after 1 hour, and phases 1-3 can - # easily exceed that. Refreshing here ensures push and PR - # creation use a valid token. - echo "Refreshing GitHub App tokens before push/PR..." + # Regenerate GitHub App tokens before Phase 4. + # Phase 3 may also have taken significant time, so refresh again + # to ensure PR creation uses a valid token. + echo "Refreshing GitHub App tokens before Phase 4..." GITHUB_TOKEN_FORK=$(generate_github_token "$INSTALLATION_ID_FORK") if [ -z "$GITHUB_TOKEN_FORK" ] || [ "$GITHUB_TOKEN_FORK" = "null" ]; then echo "ERROR: Failed to refresh GitHub App token for fork" @@ -648,7 +658,7 @@ IMPORTANT: set +e claude -p "$PR_PROMPT" \ --allowedTools "Bash Read Grep Glob" \ - --max-turns 15 \ + --max-turns 30 \ --effort max \ --model "$CLAUDE_MODEL" \ --verbose \ From e3652339cc28a0f66b041715b5e483068e454394 Mon Sep 17 00:00:00 2001 From: enxebre Date: Mon, 15 Jun 2026 10:32:36 +0200 Subject: [PATCH 2/2] ci: increase max-turns 3x for all jira-agent phases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 (solve): 100 → 300 Phase 2 (review): 75 → 225 Phase 3 (address review): 75 → 225 Phase 4 (PR creation): 30 → 90 Both rehearsal runs of CNTRLPLANE-3612 hit the 100-turn limit — once while pushing after a successful implementation, once while debugging test failures. The agent completed the implementation in both cases but ran out of turns during the verification/push tail. Tripling gives enough headroom for complex feature tickets. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../process/hypershift-jira-agent-process-commands.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh b/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh index 783d57b344b9e..fee7b43f3bec0 100755 --- a/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh +++ b/ci-operator/step-registry/hypershift/jira-agent/process/hypershift-jira-agent-process-commands.sh @@ -415,7 +415,7 @@ while IFS= read -r line; do claude -p "$ISSUE_KEY origin --ci. $FORK_CONTEXT" \ --system-prompt "$SKILL_CONTENT" \ --allowedTools "Bash Read Write Edit Grep Glob WebFetch" \ - --max-turns 100 \ + --max-turns 300 \ --effort max \ --model "$CLAUDE_MODEL" \ --verbose \ @@ -482,7 +482,7 @@ while IFS= read -r line; do --plugin-dir "${REVIEW_PLUGIN_DIR}" \ --append-system-prompt "SECURITY: Do NOT run commands that reveal git credentials like 'git remote -v' or 'git remote get-url origin'. ${SUBAGENT_PROMPT}" \ --allowedTools "Bash Read Grep Glob Task" \ - --max-turns 75 \ + --max-turns 225 \ --effort max \ --model "$CLAUDE_MODEL" \ --verbose \ @@ -567,7 +567,7 @@ IMPORTANT: set +e claude -p "$FIX_PROMPT" \ --allowedTools "Bash Read Write Edit Grep Glob" \ - --max-turns 75 \ + --max-turns 225 \ --effort max \ --model "$CLAUDE_MODEL" \ --verbose \ @@ -658,7 +658,7 @@ IMPORTANT: set +e claude -p "$PR_PROMPT" \ --allowedTools "Bash Read Grep Glob" \ - --max-turns 30 \ + --max-turns 90 \ --effort max \ --model "$CLAUDE_MODEL" \ --verbose \