# How the Task Contract Defines Pause Policies for Agent Execution in DeepSeek-Reasonix

> Discover how the DeepSeek-Reasonix task contract defines pause policies, ensuring agents request user confirmation before critical actions like irreversible operations or scope changes.

- Repository: [YHH/DeepSeek-Reasonix](https://github.com/esengine/DeepSeek-Reasonix)
- Tags: internals
- Published: 2026-08-06

---

**The task contract in DeepSeek-Reasonix defines pause policies that require the agent to stop and request user confirmation before executing irreversible operations, scope changes, or actions requiring user-specific information.**

DeepSeek-Reasonix treats every user goal as a formal *task contract* that governs when an autonomous agent must halt execution. This contract-based approach ensures safe, user-controlled operation by embedding specific pause conditions directly into the agent's system prompt, mandating stops before externally visible or irreversible actions proceed.

## What Is the Task Contract Pause Policy?

The **task contract** is a structured agreement between the user and the agent that includes a dedicated *Pause policy* section. According to the contract documentation in [`docs/TASK_CONTRACT.md`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/docs/TASK_CONTRACT.md) (lines 39-43), the policy states:

> "Unless the next step involves an **irreversible or externally visible operation**, a **scope change**, or **information only the user can provide**, keep working and report back after the task is complete."

This same directive is embedded in the runtime system through the `goalTaskContractInstructions` variable in [`internal/control/input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/input.go) (lines 73-76), which injects the pause rules into the agent's context:

> "Pause only when the next step involves an **irreversible or externally visible operation**, the requested **scope has changed**, or **progress requires information only the user can provide**. Otherwise keep working and report assumptions at the end."

## Implementation Details in the Source Code

### Contract Definition in Documentation

The canonical definition resides in [`docs/TASK_CONTRACT.md`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/docs/TASK_CONTRACT.md). This file serves as the template for all task contracts, explicitly defining the **Pause policy** section that distinguishes between safe internal operations and actions requiring user oversight.

### Runtime Injection via [`input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/input.go)

The [`internal/control/input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/input.go) file contains the `goalTaskContractInstructions` string constant that embeds the pause policy into the agent's system prompt at runtime. This ensures the contract terms are available during every turn of the conversation, allowing the agent to evaluate its next action against the pause criteria.

### Enforcement Logic in [`goal.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/goal.go)

The core enforcement mechanism lives in [`internal/control/goal.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/goal.go). This file implements the goal-state machine that interprets the contract's pause conditions through functions like `pauseFor`. When the agent plans its next action, this logic evaluates whether the operation triggers a pause requirement.

### Event Handling in [`event.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/event.go)

When a pause occurs, the system emits a specific event type defined in [`internal/event/event.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/event/event.go). The `TurnOutcomeRecoveryPaused` constant represents this state, signaling the UI layer to display the pause notice and await user input.

## Practical Example: Declaring a Custom Pause Policy

Users can define explicit pause policies when initiating goals. Here is an example of a task contract that customizes when the agent should stop:

```text
/goal Context:
I am adding a new command to the desktop composer.

Request:
Implement a slash‑command that keeps keyboard focus while suggestions are open.

Output format:
List changed files and how to verify the new behavior.

Constraints:
Do not modify the Wails JSON contract.
Do not refactor unrelated composer state.

Pause policy:
Unless the next step requires a public push, a credential, or a permanent UI change,
continue through implementation and verification before reporting back.

```

When the agent reaches a point where it would **push the change** or **modify the UI in a way visible to other users**, it automatically pauses and displays a recovery notice.

## How the Pause Policy Is Enforced at Runtime

The enforcement follows a strict evaluation pipeline:

1. **Goal Mode** reads the task contract and extracts the *Pause policy* section, applying it to every turn.

2. **Action Evaluation**: During each turn, the agent analyzes the **next planned action**:
   - **Pauses** if the action would write files, push to a public repository, publish a package, use credentials, or cause any external effect.
   - **Continues** if the action only modifies internal state or performs read-only operations.

3. **User Notification**: When paused, the UI shows the `⏸ Recovery paused` notice and awaits either a `/goal resume` command or fresh instructions from the user.

The pause notice typically appears as:

```

⏸ Automatic retries paused. Reasonix stopped repeated attempts and kept completed work.
Send "Continue" to start a fresh attempt, or add instructions to change direction.

```

## Summary

- The **task contract** in [`docs/TASK_CONTRACT.md`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/docs/TASK_CONTRACT.md) defines pause policies that mandate user confirmation before irreversible or externally visible operations.
- The `goalTaskContractInstructions` variable in [`internal/control/input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/input.go) injects these rules into the agent's runtime system prompt.
- The goal-state machine in [`internal/control/goal.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/goal.go) evaluates each planned action against the pause criteria via `pauseFor` logic.
- Pauses trigger the `TurnOutcomeRecoveryPaused` event from [`internal/event/event.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/event/event.go), displaying a recovery notice in the UI.
- Users resume paused tasks using the `/goal resume` command or by providing additional instructions.

## Frequently Asked Questions

### What triggers a pause in DeepSeek-Reasonix agent execution?

According to the source code in [`internal/control/input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/input.go), the agent pauses when the next step involves an **irreversible or externally visible operation**, a **scope change**, or when **progress requires information only the user can provide**. This includes actions like pushing to public repositories, publishing packages, using credentials, or modifying permanent UI state.

### How do I resume a paused task?

When the agent enters a paused state, the UI displays a `⏸ Recovery paused` notice. You can resume execution by sending the `/goal resume` command or by providing fresh instructions to change the direction of the task. This mechanism ensures you retain control over potentially impactful operations.

### Can I customize the pause policy for specific goals?

Yes. As documented in [`docs/TASK_CONTRACT.md`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/docs/TASK_CONTRACT.md), you can include a custom **Pause policy** section when defining your goal. This allows you to specify exactly which operations should trigger a pause—such as public pushes or credential usage—while allowing the agent to proceed autonomously with internal implementation and verification steps.

### Where is the pause state managed in the codebase?

The pause state is managed across several files: [`internal/control/goal.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/goal.go) contains the core state machine logic including the `pauseFor` function; [`internal/control/input.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/input.go) injects the pause rules via `goalTaskContractInstructions`; and [`internal/event/event.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/event/event.go) defines the `TurnOutcomeRecoveryPaused` constant used to signal the UI layer.