Skip to content

feat(planner): GitHub pre-fetch + pass-through to orchestrator (#193 PR 2)#195

Merged
Abernaughty merged 1 commit into
mainfrom
feat/issue-193-planner-tool-access
Apr 17, 2026
Merged

feat(planner): GitHub pre-fetch + pass-through to orchestrator (#193 PR 2)#195
Abernaughty merged 1 commit into
mainfrom
feat/issue-193-planner-tool-access

Conversation

@Abernaughty

Copy link
Copy Markdown
Owner

Summary

Second PR in the Issue #193 split (foundation #194 merged).

  • Planner pre-fetch: When the user's message contains GitHub issue/PR refs, the Planner now deterministically fetches their summaries via the GitHub REST API (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.
  • Session accumulation: TaskSpec.github_context is 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.
  • End-to-end pass-through: On POST /tasks/plan/{id}/submit, github_context is forwarded through task_runner.submit_run_taskinitial_state.prefetched_gathered_contextgather_context_node. The node folds the prefetched items in and filters extract_github_refs output before the network call, so a ref the Planner already fetched is never fetched again.
  • Best-effort: missing 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 passed
  • Full uv run pytest tests/ -m 'not integration' — 1061 passed (sole failure test_workspace::test_from_env_defaults is a pre-existing env-leak unrelated to this PR)
  • uv run ruff check src/ tests/ — clean
  • New tests cover: pre-fetch populates github_context and reaches the LLM as a system message, pre-fetch is skipped without GITHUB_TOKEN, dedupe across turns, LLM JSON cannot clobber github_context, pre-fetch failure doesn't break the user turn, gather_context_node reuses prefetched items, gather_context_node skips refetching refs already in prefetched.

Refs #193.

…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 Abernaughty merged commit 2c7b8b4 into main Apr 17, 2026
3 checks passed
@Abernaughty Abernaughty deleted the feat/issue-193-planner-tool-access branch April 17, 2026 20:18
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant