Skip to content

[limen LIMEN-003] Open Codex task one#22

Open
4444J99 wants to merge 1 commit into
mainfrom
limen/limen-003-dcae
Open

[limen LIMEN-003] Open Codex task one#22
4444J99 wants to merge 1 commit into
mainfrom
limen/limen-003-dcae

Conversation

@4444J99

@4444J99 4444J99 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Autonomous limen dispatch of task LIMEN-003.

Produced in an isolated worktree off origin — review before merge.

Summary by Sourcery

Enhancements:

  • Allow specifying a custom dispatch command via the LIMEN_DISPATCH_CMD environment variable for non-jules agents, with fallback to the built-in agent-dispatch command when unset.

limen task LIMEN-003
@sourcery-ai

sourcery-ai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Update agent dispatch logic to prefer a configurable LIMEN_DISPATCH_CMD when present, while defaulting the fallback path to the fixed 'agent-dispatch' command and keeping local and jules agent handling unchanged.

Sequence diagram for updated agent dispatch logic

sequenceDiagram
    participant Caller
    participant Dispatch as call_agent_dispatch
    participant Env as LIMEN_ENV
    participant Jules as _call_jules
    participant Local as _call_local_agent
    participant Builder as _build_prompt
    participant Runner as _run_cmd

    Caller->>Dispatch: call_agent_dispatch(agent, task, dry_run)
    alt agent == jules
        Dispatch->>Jules: _call_jules(task, dry_run)
        Jules-->>Dispatch: result
    else LIMEN_DISPATCH_CMD is set
        Dispatch->>Env: get(LIMEN_DISPATCH_CMD)
        Env-->>Dispatch: dispatch_cmd
        Dispatch->>Builder: _build_prompt(task)
        Builder-->>Dispatch: prompt
        Dispatch->>Runner: _run_cmd([dispatch_cmd, agent, prompt], task, dry_run)
        Runner-->>Dispatch: result
    else agent in _LOCAL_AGENTS
        Dispatch->>Local: _call_local_agent(agent, task, dry_run)
        Local-->>Dispatch: result
    else fallback to agent-dispatch
        Dispatch->>Builder: _build_prompt(task)
        Builder-->>Dispatch: prompt
        Dispatch->>Runner: _run_cmd(["agent-dispatch", agent, prompt], task, dry_run)
        Runner-->>Dispatch: result
    end
    Dispatch-->>Caller: result
Loading

File-Level Changes

Change Details Files
Adjust agent dispatch resolution order to honor an optional LIMEN_DISPATCH_CMD and simplify the default external command path.
  • When LIMEN_DISPATCH_CMD is set, build the task prompt and invoke the configured command with agent and prompt arguments via _run_cmd.
  • Retain the existing local agent and 'jules' handling paths without modification.
  • Change the non-local, non-jules fallback to always use the literal 'agent-dispatch' command instead of reading LIMEN_DISPATCH_CMD with a default value.
cli/src/limen/dispatch.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new LIMEN_DISPATCH_CMD handling changes behavior by bypassing _LOCAL_AGENTS whenever the env var is set; please confirm this override of local agents is intentional, as previously local agents were always used regardless of LIMEN_DISPATCH_CMD.
  • You now build the prompt twice in some paths (_build_prompt before the env-based dispatch and again for the default command); consider refactoring to construct the prompt once to avoid duplication and keep the flow easier to follow.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `LIMEN_DISPATCH_CMD` handling changes behavior by bypassing `_LOCAL_AGENTS` whenever the env var is set; please confirm this override of local agents is intentional, as previously local agents were always used regardless of `LIMEN_DISPATCH_CMD`.
- You now build the prompt twice in some paths (`_build_prompt` before the env-based dispatch and again for the default command); consider refactoring to construct the prompt once to avoid duplication and keep the flow easier to follow.

## Individual Comments

### Comment 1
<location path="cli/src/limen/dispatch.py" line_range="30" />
<code_context>
         return _call_jules(task, dry_run)
+    dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD")
+    if dispatch_cmd:
+        prompt = _build_prompt(task)
+        return _run_cmd([dispatch_cmd, agent, prompt], task, dry_run)
     if agent in _LOCAL_AGENTS:
         return _call_local_agent(agent, task, dry_run)
-    dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD", "agent-dispatch")
     prompt = _build_prompt(task)
-    cmd = [dispatch_cmd, agent, prompt]
+    cmd = ["agent-dispatch", agent, prompt]
</code_context>
<issue_to_address>
**suggestion:** Avoid repeated `_build_prompt` calls by computing the prompt once.

The prompt is now built in two places: inside the `dispatch_cmd` branch and again for the default path. Consider building it once after the `jules` special-case (e.g. `prompt = _build_prompt(task)`) and reusing it for both the env-based dispatch and the default `agent-dispatch` call to keep the logic DRY and centralize future prompt changes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread cli/src/limen/dispatch.py
return _call_jules(task, dry_run)
dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD")
if dispatch_cmd:
prompt = _build_prompt(task)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid repeated _build_prompt calls by computing the prompt once.

The prompt is now built in two places: inside the dispatch_cmd branch and again for the default path. Consider building it once after the jules special-case (e.g. prompt = _build_prompt(task)) and reusing it for both the env-based dispatch and the default agent-dispatch call to keep the logic DRY and centralize future prompt changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the agent dispatch logic in cli/src/limen/dispatch.py to check for the LIMEN_DISPATCH_CMD environment variable earlier in the execution flow. Feedback on this change highlights a critical issue: checking for LIMEN_DISPATCH_CMD before verifying if the agent is in _LOCAL_AGENTS bypasses the local agent check. This causes local agents to run directly via _run_cmd instead of _call_local_agent, violating the repository's Worktree Isolation protocol. It is recommended to perform the local agent check first to preserve isolation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cli/src/limen/dispatch.py
Comment on lines +28 to 36
dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD")
if dispatch_cmd:
prompt = _build_prompt(task)
return _run_cmd([dispatch_cmd, agent, prompt], task, dry_run)
if agent in _LOCAL_AGENTS:
return _call_local_agent(agent, task, dry_run)
dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD", "agent-dispatch")
prompt = _build_prompt(task)
cmd = [dispatch_cmd, agent, prompt]
cmd = ["agent-dispatch", agent, prompt]
return _run_cmd(cmd, task, dry_run)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Bypassing the _LOCAL_AGENTS check when LIMEN_DISPATCH_CMD is set in the environment causes local agents (such as codex, claude, etc.) to be executed directly via _run_cmd in the current working directory instead of using _call_local_agent. This completely bypasses the Worktree Isolation protocol, which requires spawning tasks in isolated git worktrees to prevent parallel task conflicts and dirtying the live working copy.\n\nTo fix this, the check for agent in _LOCAL_AGENTS should be performed before checking for LIMEN_DISPATCH_CMD so that local agents are always routed through _call_local_agent to preserve isolation.

    if agent in _LOCAL_AGENTS:\n        return _call_local_agent(agent, task, dry_run)\n    dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD", "agent-dispatch")\n    prompt = _build_prompt(task)\n    cmd = [dispatch_cmd, agent, prompt]\n    return _run_cmd(cmd, task, dry_run)
References
  1. Section 1 (Worktree Isolation) of the Repository Style Guide states that the Conductor Swarm must spawn tasks in isolated git worktrees instead of cloning or checking out branches in the main repository checkout. (link)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47340d70d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/src/limen/dispatch.py
Comment on lines +28 to +31
dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD")
if dispatch_cmd:
prompt = _build_prompt(task)
return _run_cmd([dispatch_cmd, agent, prompt], task, dry_run)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve isolated local dispatch when a wrapper is configured

When LIMEN_DISPATCH_CMD is exported, this branch runs before the _LOCAL_AGENTS check, so limen dispatch --agent codex|claude|opencode --live no longer goes through _isolated_local_run. In those environments a successful generic wrapper causes dispatch_tasks to mark the task dispatched and spend budget, but the code skips the local-agent worktree/commit/push/PR flow that the file documents as the default for local lanes, leaving no reviewable artifact for the claimed task.

Useful? React with 👍 / 👎.

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