Skip to content

feat(gptodo): add concurrency limit for spawn command#301

Merged
ErikBjare merged 1 commit intomasterfrom
feat/gptodo-concurrency-limit
Feb 17, 2026
Merged

feat(gptodo): add concurrency limit for spawn command#301
ErikBjare merged 1 commit intomasterfrom
feat/gptodo-concurrency-limit

Conversation

@TimeToBuildBob
Copy link
Copy Markdown
Member

@TimeToBuildBob TimeToBuildBob commented Feb 17, 2026

Summary

  • Adds --max-concurrent option to gptodo spawn (default 4) to prevent overwhelming the system with unlimited background agents
  • Before spawning, reconciles session state with actual tmux sessions to get accurate running count
  • Adds test_subagent.py with tests for session save/load/list operations

Test plan

  • All 55 gptodo tests pass
  • Typecheck passes for gptodo package
  • Manual: spawn 4 agents, verify 5th is blocked with helpful message
  • Manual: kill an agent, verify spawn succeeds again

Important

Adds concurrency limit to gptodo spawn command and tests for session management.

  • Behavior:
    • Adds --max-concurrent option to gptodo spawn command in cli.py, defaulting to 4, to limit concurrent background agents.
    • Reconciles session state with actual tmux sessions to ensure accurate running count before spawning.
  • Tests:
    • Adds test_subagent.py with tests for session save/load and list operations, including edge cases like nonexistent and corrupted sessions.

This description was created by Ellipsis for 5d32970. You can customize this summary. It will automatically update as commits are pushed.

Adds --max-concurrent option (default 4) to prevent overwhelming the
system with unlimited background agents. Before spawning, reconciles
session state with actual tmux sessions to get accurate running count.

Also adds test_subagent.py with tests for session save/load/list.
@TimeToBuildBob
Copy link
Copy Markdown
Member Author

@greptileai review

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 5d32970 in 17 seconds. Click for details.
  • Reviewed 155 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_l67rZJaQ2HTe17x3

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 17, 2026

Greptile Summary

This PR adds a concurrency limit for the gptodo spawn command to prevent overwhelming the system with unlimited background agents. The implementation adds a --max-concurrent option (default 4) that checks running sessions before spawning new ones, reconciling session state with actual tmux sessions to ensure accuracy.

Key Changes:

  • Added --max-concurrent parameter to spawn_cmd and _execute_task_agent
  • Implemented session reconciliation logic that verifies tmux session state before counting
  • Added helpful user feedback when limit is reached, showing running agents and suggesting the kill command
  • Created test_subagent.py with comprehensive tests for session management (save, load, list, error handling)

Test Coverage:
The new test file covers session CRUD operations but does not test the concurrency limiting logic itself. The PR description notes manual testing is required to verify the concurrency behavior.

Confidence Score: 4/5

  • Safe to merge with minor considerations
  • The implementation is straightforward and follows good practices. The reconciliation logic correctly verifies actual tmux session state. However, the concurrency limiting logic itself lacks automated test coverage (only session management is tested), and there's a potential edge case with race conditions if multiple spawn commands run simultaneously.
  • No files require special attention - the implementation is clean and well-structured

Important Files Changed

Filename Overview
packages/gptodo/src/gptodo/cli.py Adds --max-concurrent option to spawn command with reconciliation logic to check actual tmux session state before spawning new agents
packages/gptodo/tests/test_subagent.py New test file with comprehensive coverage for session save/load/list operations and error handling

Flowchart

flowchart TD
    A[User calls: gptodo spawn task-id] --> B{Check if background mode?}
    B -->|Yes| C{max_concurrent > 0?}
    B -->|No| H[Execute task agent]
    C -->|Yes| D[List sessions with status=running]
    C -->|No| H
    D --> E[Reconcile with tmux state]
    E --> F[Loop through running sessions]
    F --> G{check_session still running?}
    G -->|Yes| I[Add to actually_running list]
    G -->|No| F
    I --> J{len >= max_concurrent?}
    J -->|Yes| K[Display warning message]
    K --> L[List running sessions]
    L --> M[Show kill command hint]
    M --> N[Return early]
    J -->|No| H
    H --> O[Find task]
    O --> P[Build prompt]
    P --> Q[Spawn agent]
Loading

Last reviewed commit: 5d32970

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ErikBjare ErikBjare merged commit 25bf305 into master Feb 17, 2026
51 checks passed
@TimeToBuildBob TimeToBuildBob deleted the feat/gptodo-concurrency-limit branch February 28, 2026 20:50
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