Fix Buildkite detective empty event context (#660)#661
Conversation
The "Resolve event context" step runs in the agent job, but the prompt is built in the activation job. Env vars don't cross job boundaries, so all BK_* values were empty in the prompt. Write a plain text file to /tmp/gh-aw/buildkite-event.txt instead and tell the agent to read it. The file is available in the agent's filesystem at runtime. Made-with: Cursor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR centralizes Buildkite event context extraction by writing a structured file at /tmp/gh-aw/buildkite-event.txt (event_name, event_id, failure_state, commit_sha, target_url, branches, pr_numbers) instead of exporting individual BK_* environment variables. Workflow steps, prompt/template rendering, and README guidance are updated to read and use fields from that file for PR discovery and prompt generation; downstream logic now prefers pr_numbers from the file and uses branches for filtering when present. Possibly related PRs
Suggested labels
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/gh-aw-estc-pr-buildkite-detective.md (1)
108-108: Format inconsistency: empty field representationLines 108 and 114 output
pr_numbers:andbranches:(no space after colon) when explicitly empty, but lines 107 and 115 with jq will outputbranches:andpr_numbers:(space after colon) when the jq expression returns an empty string. While the agent can likely handle both, standardizing the format improves consistency.♻️ Standardize empty field format
Option 1: Add explicit empty string to match jq output:
- echo "pr_numbers:" + echo "pr_numbers: "- echo "branches:" + echo "branches: "Option 2: Use a structured format like JSON for more robust parsing:
mkdir -p /tmp/gh-aw + if [ "$GITHUB_EVENT_NAME" = "status" ]; then + jq -n \ + --arg event_name "$GITHUB_EVENT_NAME" \ + --arg event_id "$(jq -r '.id' "$GITHUB_EVENT_PATH")" \ + --arg failure_state "$(jq -r '.state' "$GITHUB_EVENT_PATH")" \ + --arg commit_sha "$(jq -r '.commit.sha' "$GITHUB_EVENT_PATH")" \ + --arg target_url "$(jq -r '.target_url // ""' "$GITHUB_EVENT_PATH")" \ + --argjson branches "$(jq '[(.branches // [])[].name]' "$GITHUB_EVENT_PATH")" \ + '{event_name: $event_name, event_id: $event_id, failure_state: $failure_state, commit_sha: $commit_sha, target_url: $target_url, branches: $branches, pr_numbers: []}' \ + > /tmp/gh-aw/buildkite-event.txt + else + jq -n \ + --arg event_name "$GITHUB_EVENT_NAME" \ + --arg event_id "$(jq -r '.check_run.id' "$GITHUB_EVENT_PATH")" \ + --arg failure_state "$(jq -r '.check_run.conclusion' "$GITHUB_EVENT_PATH")" \ + --arg commit_sha "$(jq -r '.check_run.head_sha' "$GITHUB_EVENT_PATH")" \ + --arg target_url "$(jq -r '.check_run.details_url // ""' "$GITHUB_EVENT_PATH")" \ + --argjson pr_numbers "$(jq '[(.check_run.pull_requests // [])[].number]' "$GITHUB_EVENT_PATH")" \ + '{event_name: $event_name, event_id: $event_id, failure_state: $failure_state, commit_sha: $commit_sha, target_url: $target_url, branches: [], pr_numbers: $pr_numbers}' \ + > /tmp/gh-aw/buildkite-event.txt + fi - { - echo "event_name: $GITHUB_EVENT_NAME" - if [ "$GITHUB_EVENT_NAME" = "status" ]; then - echo "event_id: $(jq -r '.id' "$GITHUB_EVENT_PATH")" - echo "failure_state: $(jq -r '.state' "$GITHUB_EVENT_PATH")" - echo "commit_sha: $(jq -r '.commit.sha' "$GITHUB_EVENT_PATH")" - echo "target_url: $(jq -r '.target_url // empty' "$GITHUB_EVENT_PATH")" - echo "branches: $(jq -r '[(.branches // [])[].name] | join(", ")' "$GITHUB_EVENT_PATH")" - echo "pr_numbers:" - else - echo "event_id: $(jq -r '.check_run.id' "$GITHUB_EVENT_PATH")" - echo "failure_state: $(jq -r '.check_run.conclusion' "$GITHUB_EVENT_PATH")" - echo "commit_sha: $(jq -r '.check_run.head_sha' "$GITHUB_EVENT_PATH")" - echo "target_url: $(jq -r '.check_run.details_url // empty' "$GITHUB_EVENT_PATH")" - echo "branches:" - echo "pr_numbers: $(jq -r '[(.check_run.pull_requests // [])[].number | tostring] | join(", ")' "$GITHUB_EVENT_PATH")" - fi - } > /tmp/gh-aw/buildkite-event.txtAlso applies to: 114-114
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/gh-aw-estc-pr-buildkite-detective.md at line 108, The workflow outputs for empty fields are inconsistent; update the echo statements to use a standard empty-field format by adding a trailing space (or an explicit empty string) so they match jq's output. Locate the two echo lines identified as echo "pr_numbers:" and echo "branches:" and change them to emit a space after the colon (e.g., echo "pr_numbers: " and echo "branches: ") or otherwise append an explicit empty string to ensure consistent formatting across the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/gh-aw-estc-pr-buildkite-detective.md:
- Line 108: The workflow outputs for empty fields are inconsistent; update the
echo statements to use a standard empty-field format by adding a trailing space
(or an explicit empty string) so they match jq's output. Locate the two echo
lines identified as echo "pr_numbers:" and echo "branches:" and change them to
emit a space after the colon (e.g., echo "pr_numbers: " and echo "branches: ")
or otherwise append an explicit empty string to ensure consistent formatting
across the file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a5b21ef-fde7-47c6-b142-b292a22f0b25
📒 Files selected for processing (1)
.github/workflows/gh-aw-estc-pr-buildkite-detective.md
Summary
Fixes #660
Resolve event contextwas writingBK_*values to$GITHUB_ENV, but those values were later consumed during prompt rendering in a different job. Because environment variables do not cross job boundaries, the detective prompt could receive empty event context (including commit SHA, PR numbers, branches, and target URL).This PR switches event context handoff to a runtime file at
/tmp/gh-aw/buildkite-event.txt, then updates the detective prompt to read that file directly.What changed
Resolve event contextstep now writes normalized fields (event_name,event_id,failure_state,commit_sha,target_url,branches,pr_numbers) to/tmp/gh-aw/buildkite-event.txtfor bothstatusandcheck_runpayloads.GH_AW_ENV_BK_*substitutions for Buildkite context./tmp/gh-aw/buildkite-event.txtfirst and usecommit_sha(pluspr_numbers/branches) from that file when resolving the target PR.Test plan
statusevent and verify/tmp/gh-aw/buildkite-event.txtcontains the expected values.check_runevent and verify the same.commit_sha(not the workflow run commit).The body of this PR is automatically managed by the Trigger Update PR Body workflow.