Skip to content

feat(plugins): apply augment_prompt on Direct-API/Codex backends#421

Merged
OBenner merged 1 commit into
developfrom
claude/augment-prompt-direct-api
Jul 13, 2026
Merged

feat(plugins): apply augment_prompt on Direct-API/Codex backends#421
OBenner merged 1 commit into
developfrom
claude/augment-prompt-direct-api

Conversation

@OBenner

@OBenner OBenner commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Problem

Plugin prompt augmentation (augment_prompt) reached the Claude SDK backend only. create_client() appends enabled plugins' contributions to the system prompt — but the Direct-API/Codex path builds its session with an empty system prompt and carries the agent's instructions in the message. So contributions from rules-steering-compiler, codebase-intelligence, skill-pack-runtime, etc. were silently absent from every non-claude build.

Change

Append the same augmentations to the agent message on the Direct-API path, right after the provider is resolved (coder.py). Extracted as a small helper _augment_direct_api_prompt for testability:

  • Guarded on provider name — no-op for claude (it already augments via create_client), so no double-application.
  • Failures degrade to the un-augmented prompt (never breaks a build).
  • Covers the primary autonomous planner + coder direct-API flow.

Scope / follow-ups

  • The follow-up planner (planner.run_followup_planner) uses a separate session builder — left as a focused follow-up.
  • Docs interaction: companion PR feat(plugins): run pre_tool/post_tool hooks on the Direct-API runtime #417 (Direct-API tool hooks) adds a plugin-development note stating augment_prompt is "Claude SDK only." Once both land, that note's augment_prompt row flips to ✅ for Direct-API. Kept out of this PR to avoid a same-file merge conflict; will reconcile on merge.

Tests

4 new unit tests (test_coder_prompt_augmentation.py): claude is not augmented (spy asserts apply not called), openai/codex are augmented with the right args, and augmentation failure degrades to the base prompt. Ruff check + format clean.

🤖 Generated with Claude Code

Plugin prompt augmentation (augment_prompt) reached the Claude SDK backend
only: create_client() appends plugin contributions to the system prompt,
but the Direct-API/Codex path builds its session with an empty system
prompt and carries the agent's instructions in the message. So enabled
plugins' prompt contributions (rules-steering-compiler, codebase-intelligence,
skill-pack-runtime, ...) were silently absent from every non-claude build.

Append the same augmentations to the agent message on the Direct-API path,
right after the provider is resolved. Guarded on provider name so the claude
provider is a no-op (it already augments via create_client) — no double
application. Failures degrade to the un-augmented prompt.

Covers the primary autonomous planner+coder flow (coder.py). The follow-up
planner (planner.run_followup_planner) uses a separate session builder and is
left for a focused follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@OBenner, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 17425d3f-297f-41c5-a601-4483da918dce

📥 Commits

Reviewing files that changed from the base of the PR and between 4ea224f and 9bf1000.

📒 Files selected for processing (2)
  • apps/backend/agents/coder.py
  • tests/test_coder_prompt_augmentation.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/augment-prompt-direct-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@OBenner OBenner merged commit 0d01248 into develop Jul 13, 2026
20 checks passed
OBenner added a commit that referenced this pull request Jul 13, 2026
…ocs (#424)

Two follow-ups to the Direct-API augment_prompt work (#421):

- The follow-up planner (planner.run_followup_planner) builds its own
  Direct-API session with a separate builder that #421 did not cover, so
  plugin prompt contributions never reached it. Apply the same augmentation
  to its message.
- Centralize the guarded helper: move the coder-local _augment_direct_api_prompt
  into plugins.runtime as the public augment_direct_api_prompt, and have both
  coder.py and planner.py call it (planner no longer needs coder-private state).
- Reconcile plugin-development.md: #417 landed a note stating augment_prompt is
  "Claude SDK only", which #421 made false. Flip the matrix row to cover
  Direct-API and Codex (delivered via the agent message) and rewrite the note.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant