Include labels in formatContext() output for issues and PRs#1298
Open
joshpayne-joby wants to merge 1 commit into
Open
Include labels in formatContext() output for issues and PRs#1298joshpayne-joby wants to merge 1 commit into
joshpayne-joby wants to merge 1 commit into
Conversation
The formatted_context block sent to the agent omitted labels for both issues and pull requests, even though the GraphQL queries already fetched them. This caused agents to incorrectly report "no labels" when labels existed, breaking any workflow that routes on label state (e.g., drift-fix routing on drift:* labels in a Drift Watcher pattern). Changes: - Add 'PR Labels:' line to PR context output - Add 'Issue Labels:' line to issue context output - Both emit 'none' when no labels are present (explicit > omitted) - Bump labels(first: 1) → labels(first: 100) in both queries; the previous cap meant only one label would appear even after the formatter fix - Update existing tests + add 'with labels' tests for both PR and issue branches Discovered while building a GitHub Actions workflow that uses this action for drift-watcher routing in an internal seed framework (joshpayne-joby/slim-routines#6). The agent self-diagnosed the gap by inspecting this action's source — a satisfying full-loop. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The `<formatted_context>` block sent to the agent currently omits labels for both issues and pull requests, even though the GraphQL queries already fetch them. This causes agents to confidently report "no labels" on issues that have labels — a real foot-gun for workflows that route on label state (e.g., drift-fix routing on `drift:*` labels).
This PR fixes both halves of the gap:
Discovery context
Found while setting up an internal seed-framework repo that uses this action for drift-watcher routing. The agent was repeatedly asserting "no labels" on a labeled issue. I asked it to inspect this action's source code from `/home/runner/work/_actions/anthropics/claude-code-action/v1/` — it identified `formatContext()` and the GraphQL pagination cap on its own. A satisfying full-loop debugging session.
After this fix lands, the workaround in our workflow (telling the agent to explicitly fetch labels via `gh issue view --json labels` in the system prompt) can be removed.
Test plan
Output sample
Before, for a labeled issue:
```
Issue Title: My Issue
Issue Author: someone
Issue State: OPEN
```
After:
```
Issue Title: My Issue
Issue Author: someone
Issue State: OPEN
Issue Labels: architecture, agent-sdk, drift:functional
```
For unlabeled issues:
```
Issue Title: My Issue
Issue Author: someone
Issue State: OPEN
Issue Labels: none
```
🤖 Generated with Claude Code