Skip to content

Architecture: Enable concurrent agent sessions per repository #360

@tbrandenburg

Description

@tbrandenburg

Problem

The current channel system uses repository-level locking instead of session-based locking, preventing multiple users from working simultaneously on the same repository.

Current Behavior

Channel Identifier: channel = repository_name (from packages/pybackend/app.py:502)

# Only ONE agent can run per repository across ALL sessions
def _mark_channel_processing(channel: str) -> bool:
    with _processing_lock:
        if channel in _processing_channels:  # Global lock per repo
            return False  # HTTP 409 Conflict to ALL sessions

Impact on Multi-User Workflows

Scenario:

👤 Developer A: Working on "my-project" → Starts agent → Channel locked
👤 Developer B: Working on "my-project" → Gets HTTP 409 Conflict  
👤 Developer C: Reviewing "my-project" → Also blocked
⏱️  3 minutes later: Developer A completes → Everyone else can proceed

Problems:

  • 🚫 No concurrent development on popular repositories
  • 🚫 Demo failures when multiple people access the same project
  • 🚫 Poor team collaboration experience with cryptic 409 errors

Proposed Solution

Session-Based Channel System

Change from:

channel = name  # Repository-wide lock (current)

Change to:

channel = f"{name}:{session_id}"  # Per-session lock (proposed)

Benefits

  • ✅ Multiple users can work simultaneously on same repository
  • ✅ Session isolation prevents cross-talk between concurrent runs
  • ✅ Better team collaboration experience
  • ✅ Eliminates demo/presentation failures

Technical Considerations

Files to Modify:

  • packages/pybackend/agent_service.py - Channel management system
  • packages/pybackend/app.py - All agent endpoint handlers
  • Tests for concurrent session behavior

Risks to Address:

  • Workspace file conflicts during concurrent operations
  • Resource contention (CPU, memory, file locks)
  • Data consistency between concurrent agent runs
  • Proper cleanup of session-based channels

Acceptance Criteria

  • Multiple users can run agents simultaneously on same repository
  • Session isolation prevents cross-talk between runs
  • Workspace file conflicts handled gracefully (locking or merge strategies)
  • Performance remains acceptable with concurrent operations
  • Updated API documentation for new concurrency model
  • Comprehensive test coverage for concurrent scenarios

Related Issues

Priority

Medium - Improves team workflows but current single-session behavior is acceptable for now.

Epic

Multi-user concurrent development support

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions