[limen LIMEN-003] Open Codex task one#22
Conversation
limen task LIMEN-003
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdate 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 logicsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new
LIMEN_DISPATCH_CMDhandling changes behavior by bypassing_LOCAL_AGENTSwhenever the env var is set; please confirm this override of local agents is intentional, as previously local agents were always used regardless ofLIMEN_DISPATCH_CMD. - You now build the prompt twice in some paths (
_build_promptbefore 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| return _call_jules(task, dry_run) | ||
| dispatch_cmd = os.environ.get("LIMEN_DISPATCH_CMD") | ||
| if dispatch_cmd: | ||
| prompt = _build_prompt(task) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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
- 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)
There was a problem hiding this comment.
💡 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".
| 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) |
There was a problem hiding this comment.
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 👍 / 👎.
Autonomous limen dispatch of task
LIMEN-003.Produced in an isolated worktree off origin — review before merge.
Summary by Sourcery
Enhancements: