Tasks and turns
Learn how to scope tasks, follow turn state, and keep agent work reviewable.
A task is a durable conversation connected to one repository context and workspace. Each request inside the task is a turn.
Task identity
A task keeps its own identifier, transcript, workspace, and review history. Each turn records the user request, agent response, tool activity, and outcome.
If a turn must be retried, LegionCode creates another run attempt for that turn. The retry does not replace the task or its earlier history.
You normally do not need internal identifiers. Include sanitized task, turn, or run-attempt identifiers only when reporting a problem.
Turn lifecycle
A typical turn moves through these stages:
- Context: resolve the workspace, provider, model, permissions, and relevant history.
- Execution: stream the agent response and approved tool activity.
- Artifact: finalize changed files and the turn diff.
- Outcome: complete, fail, cancel, interrupt, or time out with a recorded terminal state.
- Review: inspect the final response and artifact before taking a Git action.
If a turn fails, keep the task open long enough to read the error and inspect any recorded artifacts. Retry deliberately instead of assuming the previous attempt made no changes.
Writing effective tasks
State the outcome, scope, and verification together:
1Fix the empty-state copy in the repository picker. Reuse the existing component styles, do not change authentication behavior, and run its focused test.Avoid combining unrelated refactors, deployment changes, and product work in one task. Smaller scopes produce clearer diffs and make recovery easier.