shareAI-lab/learn-claude-code · error · ValueError
Assignment for {owner} is no longer active
Error message
Assignment for {owner} is no longer active What it means
The cwd-lease resolver checks the task recorded in a teammate's assignment: it must exist, be in_progress or completed, and still be owned by that owner. If the task was reassigned, reset to pending, or the assignment references a stale/deleted task, the lease is dead and this ValueError propagates (surfaces to the agent as an Error: message from _agent_cwd).
Source
Thrown at s15_integrated_harness/code.py:477
path, error = _registered_worktree(task.worktree)
return (path or WORKDIR), error
def assignment_cwd(owner: str) -> Path:
with task_lock:
assignment = teammate_assignments.get(owner)
task = _owner_in_progress(owner)
if task and (not assignment or assignment.get("task_id") != task.id):
cwd, error = task_worktree_cwd(task)
if error:
raise ValueError(error)
assignment = {"task_id": task.id, "cwd": cwd}
teammate_assignments[owner] = assignment
elif not assignment:
return WORKDIR
task = load_task(str(assignment["task_id"]))
if task.status not in {"in_progress", "completed"} or task.owner != owner:
raise ValueError(f"Assignment for {owner} is no longer active")
cwd, error = task_worktree_cwd(task)
if error:
raise ValueError(error)
if cwd.resolve() != Path(assignment["cwd"]).resolve():
raise ValueError(f"Assignment cwd changed for task {task.id}")
return cwd
def release_completed_assignment(owner: str) -> bool:
"""Release a completed cwd lease only at a model turn boundary."""
with task_lock:
assignment = teammate_assignments.get(owner)
if not assignment:
return False
task = load_task(str(assignment["task_id"]))
if task.status != "completed" or task.owner != owner:
return False
teammate_assignments.pop(owner, None)View on GitHub (pinned to 985456f4ad)
Solutions
- Restart the session so assignments rebuild from current task state (the stale in-memory lease is dropped).
- Avoid resetting/reassigning tasks that other sessions actively own; complete or release them first.
- If state is inconsistent, remove the stale assignment by restarting or releasing via release_completed_assignment().
Defensive patterns
Strategy: try-catch
Validate before calling
def assignment_alive(assignment: dict) -> bool:
try:
task = load_task(str(assignment["task_id"]))
except Exception:
return False
return task.status in {"in_progress", "completed"} and task.owner is not None Try / catch
try:
cwd = _agent_cwd_for(owner)
except ValueError as e:
if "no longer active" in str(e):
# session state is stale: restart or re-claim the task; do not retry blindly
raise Prevention
- Don't reset/reassign tasks owned by live sessions.
- Restart sessions after bulk task resets.
- Use one session per owner at a time.
When it happens
Trigger: Owner's assigned task got its status flipped to pending or owner changed while the agent held the lease; task file deleted; assignment dict references a task_id that no longer loads; concurrent admin action resetting tasks mid-session.
Common situations: Two sessions for the same owner; a task reset/reassign tool used while an agent was mid-turn; leftover in-memory assignments after the tasks directory was wiped.
Related errors
- Assignment cwd changed for task {task.id}
- Assignment for {owner} is no longer active
- workflow run {run_id} is already active
AI-assisted analysis of shareAI-lab/learn-claude-code@985456f4ad (2026-08-14).
Data as JSON: /api/errors/609fd3f6a6bfe802.
Report an issue: GitHub.