Skip to content

feat(ai): structured evidence-backed subagent prompt + parent-LLM inheritance (PR1 1.b/1.c)#1279

Merged
ocervell merged 4 commits into
ai-resiliencyfrom
fix/ai-subagent-prompt
Jul 5, 2026
Merged

feat(ai): structured evidence-backed subagent prompt + parent-LLM inheritance (PR1 1.b/1.c)#1279
ocervell merged 4 commits into
ai-resiliencyfrom
fix/ai-subagent-prompt

Conversation

@ocervell

@ocervell ocervell commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What (PR 1, parts 1.b + 1.c + a subagent-runnability fix)

1.b/1.c — structured, evidence-backed subagent prompt. When the ai task spawns a subagent, its prompt becomes a structured template whose "already known" section is auto-assembled from workspace findings for the subagent's target(s), so it doesn't redo work.

  • build_subagent_prompt(objective, targets, evidence) — wraps the LLM-supplied objective (verbatim) in ## Objective / ## Scope / ## Already known (do not re-run) / ## Expected output.
  • _gather_subagent_evidence(ctx, targets, limit=40) — queries the workspace (single source of truth incl. this run's live findings, per fix(ai): make query_workspace the single source of truth (local-driver union) #1278) for findings matching the targets; token-bounded; best-effort (failure → "", never breaks the spawn).
  • Wired into _run_runner's name=="ai" branch. 1.a (permissions) untouched — out of scope.

Subagent LLM inheritance (fold-in). E2E testing surfaced that a spawned subagent fell back to CONFIG.addons.ai.default_model — a different provider than the parent (anthropic-direct vs openrouter) with no key → AuthenticationError before it ran, so subagents never actually ran. Fixed: carry the parent's resolved model/api_key/api_base on ActionContext and setdefault them onto the child opts at spawn (explicit LLM-supplied model still wins).

Verification

  • Unit: TestBuildSubagentPrompt, TestGatherSubagentEvidence, and TestRunRunner tests for the structured prompt + LLM inheritance (+ explicit-model-wins). test_ai_actions.py 97 passed; no new failures vs baseline.
  • E2E (live subagent run): subagent runs to SUCCESS (no AuthError), receives the structured prompt with all four sections, and its spawned nmap nests under the conversation via session_id.

Known limitation (accepted, v1)

The $or host/ip/url evidence match is exact — matched_at-only findings on URL-only targets aren't gathered yet (deliberate follow-up).

Part of the AI-task series → ai-resiliency (#1241).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76307ee7-3e84-4c46-a283-36926eadf610

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ai-subagent-prompt

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.

A spawned subagent fell back to CONFIG.addons.ai.default_model, which may be a
different provider than the parent (e.g. anthropic-direct vs the parent's
openrouter) with no key set -> AuthenticationError before the subagent did
anything, so subagents never actually ran.

Carry the parent's resolved LLM config on ActionContext (api_key/api_base; model
already present) and setdefault them onto the child opts at the name=='ai' spawn
branch (an explicit LLM-supplied model still wins). Verified E2E: subagents now
run to SUCCESS and receive the structured prompt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NNjPggRSVZ2xnLb7ZxWP5H
@ocervell ocervell changed the title feat(ai): structured, evidence-backed subagent prompt (PR1 1.b/1.c) feat(ai): structured evidence-backed subagent prompt + parent-LLM inheritance (PR1 1.b/1.c) Jul 5, 2026
@ocervell ocervell merged commit 0fc7db3 into ai-resiliency Jul 5, 2026
3 checks passed
@ocervell ocervell deleted the fix/ai-subagent-prompt branch July 5, 2026 19:20
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