feat(planner): GitHub pre-fetch + pass-through to orchestrator (#193 PR 2)#195
Merged
Merged
Conversation
…PR 2) The Planner now deterministically pre-fetches GitHub issues/PRs mentioned in the user's message (e.g. "fix #42", "acme/widgets#7") before the LLM turn and injects the summaries into the system prompt so the Planner can orient the task without spending tool tokens or asking the user to paste issue content. TaskSpec gains a `github_context` field that accumulates across the session (deduped by synthetic path). On submit, the API pass-through delivers it to the orchestrator via a new `GraphState.prefetched_gathered_context`; `gather_context_node` folds those items in and filters the extracted refs BEFORE the network call so the same ref is never fetched twice. Guard: `_apply_spec_updates` ignores `github_context` in the LLM's extracted JSON — only the deterministic pre-fetch can populate it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Abernaughty
added a commit
that referenced
this pull request
Apr 17, 2026
… (refs #193) The Planner's system prompt unconditionally declared "ZERO tool access", causing the LLM to tell users it could not look up GitHub issues even when PR #195's deterministic pre-fetch had already injected the issue body as a secondary system message. Users reported the bug with "Review and implement the fix for GitHub Issue #113" — the Planner replied "I don't have access to GitHub" despite the issue content being in its context window. Changes: - _PLANNER_SYSTEM_PROMPT now explains the pre-fetch flow and explicitly forbids denying GitHub access when the PRE-FETCHED GITHUB CONTEXT block is present. - _format_github_context_block wraps the payload in clear start/end markers that the system prompt references by name. - _prefetch_github_refs_for_message logs a warning (not silent skip) when refs were detected but GITHUB_TOKEN is missing or the fetch returned zero items, so operators can diagnose environment issues. - Four new tests in TestPlannerSystemPromptReconciliation cover: the system prompt no longer contains "ZERO tool access", the context block carries start/end markers, empty inputs produce no block, and the new warning log fires when refs are detected without a token. Closes the AC #3 gap in issue #193 (Planner "fetches" GitHub issues when referenced). All other ACs were already satisfied by PRs #194-#196. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 17, 2026
Abernaughty
added a commit
that referenced
this pull request
Apr 17, 2026
… (refs #193) (#197) The Planner's system prompt unconditionally declared "ZERO tool access", causing the LLM to tell users it could not look up GitHub issues even when PR #195's deterministic pre-fetch had already injected the issue body as a secondary system message. Users reported the bug with "Review and implement the fix for GitHub Issue #113" — the Planner replied "I don't have access to GitHub" despite the issue content being in its context window. Changes: - _PLANNER_SYSTEM_PROMPT now explains the pre-fetch flow and explicitly forbids denying GitHub access when the PRE-FETCHED GITHUB CONTEXT block is present. - _format_github_context_block wraps the payload in clear start/end markers that the system prompt references by name. - _prefetch_github_refs_for_message logs a warning (not silent skip) when refs were detected but GITHUB_TOKEN is missing or the fetch returned zero items, so operators can diagnose environment issues. - Four new tests in TestPlannerSystemPromptReconciliation cover: the system prompt no longer contains "ZERO tool access", the context block carries start/end markers, empty inputs produce no block, and the new warning log fires when refs are detected without a token. Closes the AC #3 gap in issue #193 (Planner "fetches" GitHub issues when referenced). All other ACs were already satisfied by PRs #194-#196. Co-authored-by: Claude Opus 4.7 (1M context) <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
Second PR in the Issue #193 split (foundation #194 merged).
fetch_refs_as_context_items, reused from PR 1) and injects them into the system prompt. The Planner can orient the task without asking the user to paste content and without spending tool-call tokens.TaskSpec.github_contextis a new field that accumulates pre-fetched items across the conversation, deduped by synthetic path (github://owner/repo/issues/N). The LLM cannot override or populate this field — only the pre-fetch helper writes to it.POST /tasks/plan/{id}/submit,github_contextis forwarded throughtask_runner.submit→_run_task→initial_state.prefetched_gathered_context→gather_context_node. The node folds the prefetched items in and filtersextract_github_refsoutput before the network call, so a ref the Planner already fetched is never fetched again.GITHUB_TOKEN, network errors, and 404s are swallowed — the Planner turn still completes.Scope
PR 2 intentionally does not yet bind filesystem read-only tools to the Planner LLM. Pre-fetch covers the self-dev gate workflow (which is all about GitHub issue refs); filesystem tool binding can be a follow-up once the need is concrete.
PR 3 will cover the Architect's two-phase (no-tools → tools-on-insufficient-context) access and an integration test for the "Fix issue #113" E2E flow.
Test plan
uv run pytest tests/test_planner.py tests/test_gather_context.py tests/test_github_fetch.py -v— 125 passeduv run pytest tests/ -m 'not integration'— 1061 passed (sole failuretest_workspace::test_from_env_defaultsis a pre-existing env-leak unrelated to this PR)uv run ruff check src/ tests/— cleangithub_contextand reaches the LLM as a system message, pre-fetch is skipped withoutGITHUB_TOKEN, dedupe across turns, LLM JSON cannot clobbergithub_context, pre-fetch failure doesn't break the user turn,gather_context_nodereuses prefetched items,gather_context_nodeskips refetching refs already in prefetched.Refs #193.