Skip to content

Conversation

@lossyrob
Copy link
Owner

@lossyrob lossyrob commented Nov 27, 2025

Summary

This phase updates all 14 PAW agent instruction files to include the new handoff component and stage-specific handoff behavior, enabling intelligent stage navigation and workflow transitions.

Changes

Handoff Component

  • Created agents/components/handoff-instructions.component.md with consolidated handoff logic covering:
    • Reading Handoff Mode from WorkflowContext.md (manual/semi-auto/auto)
    • Mode-specific behavior patterns
    • Handoff tool invocation with intelligent agent name mapping
    • Prompt generation tool invocation for customization
    • Prerequisite validation before handoffs

Agent Updates

All 14 agents updated to include {{HANDOFF_INSTRUCTIONS}} component and stage-specific handoff sections:

Standard Workflow Agents:

  • PAW-01A Specification → Code Research handoff
  • PAW-01B Spec Researcher → Return to Spec handoff
  • PAW-02A Code Researcher → Implementation Plan handoff
  • PAW-02B Impl Planner → Implementation Phase 1 handoff
  • PAW-03A Implementer → Implementation Review handoff
  • PAW-03B Impl Reviewer → Next Phase/Docs handoff
  • PAW-04 Documenter → Final PR handoff
  • PAW-05 PR → Workflow complete (no further handoffs)

Review Workflow Agents:

  • PAW-R1A Understanding → Impact Analysis handoff
  • PAW-R1B Baseline Researcher → Return to Understanding handoff
  • PAW-R2A Impact Analyzer → Gap Analysis handoff
  • PAW-R2B Gap Analyzer → Feedback Generation handoff
  • PAW-R3A Feedback Generator → Feedback Critic handoff
  • PAW-R3B Feedback Critic → Feedback iteration/post handoff

Mode-Aware Behavior

Each agent now adapts handoff behavior based on mode:

  • Manual: Present next-step options, wait for user command
  • Semi-Auto: Auto-chain at routine transitions, pause at decision points
  • Auto: Chain immediately (requires local review strategy)

Verification

Automated ✅

  • All 87 unit tests pass: npm test
  • TypeScript compilation succeeds: npm run compile
  • Agent linter passes for all agents except PAW-01A (pre-existing token limit issue, documented in WorkflowContext.md)

Manual (Outstanding)

  • Spec Agent presents next-step options after completion in Manual mode
  • Spec Research Agent auto-returns to Spec in Semi-Auto mode after user types continue
  • Code Research Agent auto-invokes Implementation Plan in Semi-Auto mode
  • Implementation Review Agent pauses after Phase PR in Semi-Auto mode
  • Implementation Review Agent auto-invokes next phase in Auto mode
  • All agents correctly parse inline instructions
  • Review workflow agents follow same handoff patterns
  • Final PR Agent does not present handoff options (terminal stage)

Artifacts

  • Implementation Plan: .paw/work/workflow-handoffs/ImplementationPlan.md
  • Handoff Component: agents/components/handoff-instructions.component.md

Notes

  • PAW-01A Specification agent exceeds the 6500 token lint error limit (~6831 tokens). This is a pre-existing issue documented in WorkflowContext.md that will be addressed separately.
  • Several agents have token count warnings (exceed 3500 warning threshold) but all pass the error threshold.

#69 (partial - Phase 4 of 6)
Related: #60


🐾 Generated with PAW

…fic handoff behavior

- Create agents/components/handoff-instructions.component.md with consolidated handoff logic
- Add {{HANDOFF_INSTRUCTIONS}} component include to all 14 PAW agents
- Update stage-specific handoff sections for each agent with mode-aware behavior
- Standard workflow agents (PAW-01A through PAW-05): handoff patterns for spec/research/planning/implementation/review/docs/pr stages
- Review workflow agents (PAW-R1A through PAW-R3B): handoff patterns for understanding/baseline/impact/gap/feedback/critic stages
- Document PAW-01A token limit issue in WorkflowContext.md (pre-existing, will be addressed separately)
- Mark Phase 4 complete in ImplementationPlan.md

Automated verification:
- All 87 unit tests pass
- TypeScript compilation succeeds
- Agent linter passes for all agents except PAW-01A (pre-existing token issue)
@lossyrob
Copy link
Owner Author

🐾 Implementation Reviewer 🤖:

Review Summary

Phase 4 implementation reviewed and verified. All automated checks pass.

What Changed

New Component Created:

  • agents/components/handoff-instructions.component.md - Consolidated handoff logic for all agents

14 Agents Updated:
All agents now include the {{HANDOFF_INSTRUCTIONS}} component placeholder and stage-specific handoff sections. The template rendering system (in agentTemplateRenderer.ts) expands this placeholder at runtime.

Quality Assessment

Check Status
Unit tests (87) ✅ Pass
TypeScript compilation ✅ Pass
Agent linter (all except PAW-01A) ✅ Pass
Code necessity review ✅ No unused code
Duplication check ✅ No duplication
Design decisions ✅ Appropriate

Token Count Analysis

Agents with warnings (exceed 3500 threshold but under 6500 error limit):

  • PAW-02A: 4782 tokens
  • PAW-02B: 6339 tokens
  • PAW-03A: 4948 tokens
  • PAW-03B: 4998 tokens
  • PAW-04: 5665 tokens
  • PAW-R1A: 5778 tokens
  • PAW-R2A: 3571 tokens
  • PAW-R2B: 5043 tokens
  • PAW-R3A: 4017 tokens
  • PAW-X: 5687 tokens (uses special higher threshold)

PAW-01A exceeds error limit (6831 tokens) - pre-existing issue documented in WorkflowContext.md.

Notes for Human Reviewer

  1. The negative diff in some agents (PAW-02B, PAW-03A, PAW-03B, PAW-04, PAW-05) is intentional - verbose handoff template blocks were replaced with the component include and concise stage-specific guidance.

  2. Manual verification of handoff flows across all three modes (manual, semi-auto, auto) is recommended after merge.

  3. The paw-specification.md does not yet document the Handoff Mode field. This would typically be addressed in Phase 5 (Testing) or Phase 6 (Documentation) per the implementation plan.


Ready for human review.


### Specification Handoff

**Next stage**: PAW-02A Code Researcher
Copy link
Owner Author

@lossyrob lossyrob Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be conditional - when having produced a spec research prompt, then the next stage is spec research. If the SpecResearch.md exists and the spec was generated, then code researcher. User should have the option in manual mode to skip spec research and go straight to code research even if that's the next stage. In semi-auto mode, in the case the next stage is spec research, then that is automatic. The pause is appropriate only before code research.

### Invoking Handoffs

When transitioning to another stage:
1. Map user request to target agent (e.g., "research" → `PAW-01B Spec Researcher`)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent needs to know this mapping, so list them here concisely.


### Prerequisite Validation

Before handoff, validate required artifacts exist. If missing, provide actionable error with artifact path and which command to run first.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't validate before handoff. Let the next agent check for its prerequisites and suggest next steps if they aren't met.

Agents need to be given information about what agent to suggest if their prerequisites fail - currently only next stage is stated for success case.

@@ -0,0 +1,30 @@
````markdown
## Handoff Mode and Stage Navigation
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should indicate that the user can ask the Status agent for help navigating the workflow - this is applicable to every stage. This should be states concisely as part of the handoff message.

@lossyrob lossyrob force-pushed the feature/workflow-handoffs_phase4 branch from da96cb2 to f6799c0 Compare December 2, 2025 17:14
Updates handoff-instructions.component.md:
- Add command-to-agent mapping table (#2569868767)
- Add 'continue' command behavior for default next stage
- Replace 'Prerequisite Validation' with 'Getting Help' section (#2569885927)
- Add prompt file option mention in handoff messages (#2569886459)
- Add Status Agent help guidance in handoff messages (#2569888255)

Updates PAW-01A Specification handoff (#2569861784):
- Make next stage conditional: spec research vs code research
- In manual mode, allow skipping spec research to go directly to code research
- Semi-Auto auto-chains to spec research, pauses before code research

Updates other agent handoff sections (voice notes feedback):
- PAW-02B: Clarify local vs prs strategy options
- PAW-03A: Explicit 'handoff to reviewer' in semi-auto/auto
- PAW-03B: Detailed prs vs local strategy handoff logic
- PAW-04: Add review comment handling handoff
- PAW-05: Clarify review command for Final PR
- PAW-R1A: Conditional handoff for baseline research

#119 (comment)
#119 (comment)
#119 (comment)
#119 (comment)
#119 (comment)
@lossyrob
Copy link
Owner Author

lossyrob commented Dec 2, 2025

🐾 Implementation Reviewer 🤖:

PR Review Comments Verification

All PR review comments and voice notes have been successfully addressed. Changes verified and pushed.


Detailed Comment Tracking

Comment #2569868767 - Command-to-Agent Mapping

Request: List command-to-agent mapping concisely in handoff component
Addressed in: Commit ce191e2
Solution: Added comprehensive Command Mapping table in handoff-instructions.component.md with 9 common user commands mapped to their target agents, plus context-sensitive behavior notes.

Comment #2569885927 - Prerequisite Validation

Request: Don't validate before handoff; let next agent check prerequisites and inform which agent to suggest if prerequisites fail
Addressed in: Commit ce191e2
Solution: Removed "Prerequisite Validation" section entirely. Replaced with "Getting Help" section that directs users to Status Agent for workflow navigation guidance. Next agents now handle their own prerequisite checks.

Comment #2569886459 - Prompt File Option

Request: Handoff message must indicate user has option to generate prompt files
Addressed in: Commit ce191e2
Solution: Added explicit guidance in component: "Always mention the prompt file option in handoff messages: 'Say generate prompt to create a customizable prompt file instead.'"

Comment #2569888255 - Status Agent Guidance

Request: Section should indicate users can ask Status agent for help navigating workflow, applicable to every stage
Addressed in: Commit ce191e2
Solution: Added "Getting Help" section with requirement to include in handoff messages: "Say status or help for workflow guidance."

Comment #2569861784 - Conditional Specification Handoff

Request: Spec handoff needs to be conditional - when producing spec research prompt, next stage is spec research; if SpecResearch.md exists, next is code research; manual mode should allow skipping research
Addressed in: Commit ce191e2
Solution: Complete rewrite of PAW-01A Specification handoff section with two conditional branches:

  • If spec research prompt generated: Next stage is Spec Researcher (manual allows skip, semi-auto auto-chains, auto immediate)
  • If SpecResearch.md exists or research skipped: Next stage is Code Researcher (manual presents options, semi-auto pauses at decision point, auto immediate)

Voice Notes Feedback Addressed

PAW-02B Impl Planner

Issue: Handoff should clarify local vs prs strategy options, avoid requiring "Phase 1" specification
Solution: Simplified handoff to just say implement without phase number, clarified that in local strategy user can chat to update plan

PAW-03A Implementer

Issue: Semi-auto/auto mode should explicitly say "immediate handoff to reviewer"
Solution: Updated handoff section: "Semi-Auto/Auto: Immediate handoff to reviewer"

PAW-03B Impl Reviewer

Issue: "All modes pause" is not true for local strategy; handoff to "PAW 03B" should use full agent name
Solution: Split handoff into two strategy-specific branches (prs vs local), each with clear mode behavior. All agent references use full names like "PAW-03A Implementer"

PAW-04 Documenter

Issue: Should understand review process and be able to handoff to itself with review context
Solution: Added review comment handling handoff: "After PR review comments: Say review to address comments (handoff to self with review context)"

PAW-05 PR Agent

Issue: "Address review comments on PR number X" too verbose, should just be "review"
Solution: Simplified command language and clarified that PR is auto-discovered: "After PR review: Say review to address comments"

PAW-R1A Understanding Agent

Issue: Next stage conditional based on whether baseline research is done; must handoff with prompt path when research needed
Solution: Mirrored PAW-01A conditional structure with two branches:

  • If baseline research prompt generated: Next stage is Baseline Researcher with prompt path in semi-auto mode
  • If CodeResearch.md exists: Next stage is Impact Analyzer

Continue Command

Issue: User should be able to say "continue" to proceed with default next stage
Solution: Added "Continue command" section in handoff component: "When user says continue, proceed to the default next stage as if in semi-auto/auto mode"

User-Friendly Command Names

Issue: Users shouldn't have to say "PAW-03B" or include numbers; should say "spec", "planner", "implementer", "reviewer"
Solution: Command mapping table uses friendly names like spec, research, plan, implement, review, docs, pr, status, help


Overall Summary

Changes Made by Implementation Agent

  • Updated handoff-instructions.component.md with comprehensive improvements:
    • Command-to-agent mapping table
    • Continue command behavior
    • Getting Help section (replaced Prerequisite Validation)
    • Prompt file and Status Agent mentions in handoff messages
  • Updated 7 agent files with conditional/clarified handoff logic:
    • PAW-01A: Conditional spec research vs code research handoff
    • PAW-02B: Simplified command language
    • PAW-03A: Explicit reviewer handoff
    • PAW-03B: Strategy-specific handoff branches
    • PAW-04: Review comment handling
    • PAW-05: Simplified review command
    • PAW-R1A: Conditional baseline research vs impact analysis handoff

Verification Results

  • ✅ All 87 unit tests pass
  • ✅ TypeScript compilation succeeds
  • ✅ All review comments fully addressed
  • ✅ All voice notes feedback incorporated
  • ✅ No code necessity issues found
  • ✅ No code duplication found
  • ✅ Design decisions appropriate and well-justified

Ready for Re-Review

All requested changes have been implemented. The handoff system now provides:

  1. Clear command-to-agent mapping for user-friendly navigation
  2. Conditional handoffs based on workflow state (spec research, baseline research)
  3. Strategy-aware behavior (prs vs local)
  4. Mode-aware behavior (manual vs semi-auto vs auto)
  5. Consistent guidance to Status Agent for help
  6. Prompt file generation options at every stage
  7. Continue command for default progression

The phase is ready for final human review and approval.

Next: Invoke Evaluation Stage agents (PAW-R2A Impact Analysis, PAW-R2B Gap Analysis) with these understanding artifacts.
```

{{HANDOFF_INSTRUCTIONS}}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handoff instructions, especially the table, are specific to the PAW implementation workflow, not the PAW Review workflow. There should be a separate handoff component for review workflows. Similarly, I noticed that the {{PAW_CONTEXT}} is also included in the review agents, but this is a PAW implementation workflow specific context. Please also remove that.

@@ -0,0 +1,49 @@
````markdown
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not need the markdown wrapper, remove.

| `review`, `reviewer` | PAW-03B Impl Reviewer |
| `docs`, `documenter`, `documentation` | PAW-04 Documenter |
| `pr`, `final pr` | PAW-05 PR |
| `status`, `help` | PAW-X Status Update |
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a stronger command for addressing PR review comments. This is for the Implemntation Planner, Implementer (or Impl Reviewer who hands off to Impl), Docs, and PR. A phrase meaning, there are new comments go address them. This is for PR mode only. This should be a clear step in the handoff instructions.

**prs strategy** (Phase PR opened):
- All Modes: Pause (wait for human PR review and merge)
- After PR merged, more phases remain: Present `implement`, `status`
- After PR merged, all phases complete: Present `docs`, `status`
Copy link
Owner Author

@lossyrob lossyrob Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a conditional for before PR merged, PR has comments that need to be addressed. When asked to address PR comments it should hand off to the implementer agent.

- [List of commits with brief descriptions]
**prs strategy** (Docs PR opened):
- All Modes: Pause after Docs PR (wait for human review)
- After PR review comments: Say `review` to address comments (handoff to self with review context)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'review' might not be the right word here. Perhaps "address comments". Or "check pr".

Addresses PR review comments from December 3, 2025:

1. Comment #2585581858: Remove markdown wrapper from handoff-instructions.component.md
   - Removed ````markdown at start and ```` at end

2. Comment #2585473074: Separate review workflow handoff instructions
   - Created review-handoff-instructions.component.md for PAW-R* agents
   - Removed {{HANDOFF_INSTRUCTIONS}} and {{PAW_CONTEXT}} from all six PAW-R* agents
   - These placeholders are implementation workflow specific, not review workflow specific

3. Comment #2585598107: Add 'address comments' command for PR review comments
   - Added 'address comments' and 'check pr' commands to handoff-instructions.component.md
   - Commands apply to Impl Planner, Implementer/Impl Reviewer, Docs, and PR agents

4. Comment #2585602054: Conditional handoff when PR has comments
   - Updated PAW-03B Impl Reviewer handoff logic
   - When PR has review comments and not merged, present 'address comments' or 'check pr'

5. Comment #2585604450: Clarify PR review comment terminology
   - Changed PAW-04 Documenter to use 'address comments' or 'check pr' instead of 'review'
   - Improves clarity when referring to addressing PR review comments

Links:
- #114 (comment)
- #114 (comment)
- #114 (comment)
- #114 (comment)
- #114 (comment)
@lossyrob
Copy link
Owner Author

lossyrob commented Dec 3, 2025

🐾 Implementation Reviewer 🤖:

Review Comments Addressed

All review comments from December 3, 2025 have been addressed. Here's the detailed tracking:

Comment #2585581858 - Remove markdown wrapper

What was done: Removed markdown code fence wrapper from handoff-instructions.component.md
Commit: 2148c49
Verification: File now contains only raw markdown content without ````markdown` wrapper

Comment #2585473074 - Separate review workflow handoff instructions

What was done:

  • Created new review-handoff-instructions.component.md for PAW-R* agents
  • Removed {{HANDOFF_INSTRUCTIONS}} and {{PAW_CONTEXT}} from all six PAW-R* agents
  • These placeholders are implementation workflow specific, not review workflow specific
    Commit: 2148c49
    Verification: Verified with grep that no review agents contain these placeholders

Comment #2585598107 - Add 'address comments' command for PR review comments

What was done:

  • Added "Addressing PR Review Comments" section to handoff-instructions.component.md
  • Introduced address comments and check pr commands
  • Documents which agents handle which PR types (Planning PR, Phase PR, Docs PR, Final PR)
  • Workflow: Implementer makes changes → Impl Reviewer verifies and pushes
    Commit: 2148c49
    Verification: Section clearly documents PR review comment workflow (prs strategy only)

Comment #2585602054 - Conditional handoff when PR has comments

What was done:

  • Updated PAW-03B Impl Reviewer handoff section
  • Added condition: "If PR has review comments and not merged: Present address comments or check pr"
  • Maintains existing handoff flow after PR merged
    Commit: 2148c49
    Verification: Logic correctly distinguishes "PR has comments" vs "PR merged" states

Comment #2585604450 - Clarify PR review comment terminology

What was done:

  • Changed PAW-04 Documenter to use address comments or check pr instead of review
  • Improves clarity when referring to addressing PR review comments
    Commit: 2148c49
    Verification: Consistent with new terminology throughout handoff instructions

Additional Bug Fix

What was done: Fixed invokeAgent in handoffTool.ts to use target_agent parameter correctly
Commit: d4bb451
Issue: Chat mode wasn't receiving the correct agent name parameter
Fix: Changed mode: params.target_agent in the workbench.action.chat.open command call

Overall Summary

The Implementation Agent successfully addressed all five review comments from December 3, 2025 regarding:

  1. Removing markdown wrappers from component files
  2. Separating implementation and review workflow handoff instructions
  3. Adding clear commands for addressing PR review comments
  4. Implementing conditional handoff logic when PRs have comments
  5. Clarifying terminology for PR review comment workflows

Additionally, a bug was fixed in the handoff tool to ensure proper agent invocation in chat mode.

Testing: All 87 tests pass ✅
Code quality: Changes are surgical and focused on addressing review feedback
Documentation: All affected agent files properly updated with new handoff behavior

Ready for re-review and approval.

@lossyrob lossyrob merged commit bf46a77 into feature/workflow-handoffs Dec 3, 2025
1 check failed
@lossyrob lossyrob deleted the feature/workflow-handoffs_phase4 branch December 3, 2025 16:27
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.

2 participants