Skip to content

🐛 PAF Core fails to route A2A requests to downstream agents in production (PAR mode) #9

@syumpx

Description

@syumpx

Summary

PAF Core Agent deployed via PAR/APKG fails to route user requests to configured downstream A2A agents (e.g., Vivid Commenter). Instead, PAF Core answers requests directly that should be delegated.

Root Cause

Architectural mismatch between development (main.py) and production (par_adapter.py):

  • Development: Multi-agent components initialized once at app startup, reused across requests
  • Production: UPEE Engine created per-request without registry/selector, discovery service never completes before shutdown

Evidence

  • Logs show a2a_agent_match: false despite Vivid Commenter being configured in A2A_AGENT_APPS
  • Discovery service lifecycle is per-request (starts at 00:39:45, shuts down at 00:39:54)
  • Plan phase checks if self.selector and self.registry: → both are None

Impact

  • 100% routing failure in production
  • Multi-agent coordination completely broken
  • PAF Core cannot delegate specialized tasks

Proposed Solution

Add PAR application lifecycle hooks to par_adapter.py to initialize multi-agent components once at startup, store in app.state, and reuse across all requests.

Implementation Steps

  1. Add startup() and shutdown() lifecycle hooks to par_adapter.py
  2. Initialize discovery service, registry, selector, client pool in startup
  3. Update UPEEEngine to accept optional multi-agent components
  4. Wire components in handle_chat_request (gRPC handler)
  5. Update ExecutePhase to use client pool
  6. Add comprehensive tests (unit, integration, E2E)

Files to Modify

  • src/par_adapter.py - Add lifecycle hooks, update handler
  • src/core/upee_engine.py - Accept multi-agent components
  • src/core/plan.py - Add debug logging
  • src/core/execute.py - Use client pool

Timeline

Estimated 5-6 hours including implementation, testing, and validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions