How Reasonix Task Contract and Pause Policy Ensure Structured Completion
Reasonix enforces a mandatory task contract and pause policy inside every active-goal turn, requiring the model to honor explicit constraints, pause before irreversible actions, and only report completion after verifying all contractual obligations are met.
DeepSeek-Reasonix implements a deterministic safety framework that governs autonomous AI execution. When users submit goals via the controller, the system prepends a structured task contract to the model's prompt and activates a pause policy that halts execution on risky operations. This architecture ensures that autonomous agents proceed only when safe and pause for explicit user confirmation when facing ambiguity or irreversible changes.
The Active-Goal Block and Task Contract
When a user issues a goal through c.Submit("/goal fix the parser"), the controller constructs an active-goal block that is prepended to the model's prompt. This block embeds the contractual rules defined in goalTaskContractInstructions within internal/control/input.go (lines 71-77).
The task contract imposes four strict obligations on the model:
-
Honor explicit sections — The model must respect Context, Request, Output format, Constraints, and Checkpoint/Pause policy sections when present in the user's message. If absent, the model infers a lightweight contract from the conversation history and workspace state.
-
Preserve scope and output format — The model cannot invent new requirements or hide uncertainties. When using default assumptions, it must explicitly state them.
-
Pause on risk — Execution must halt when the next step involves an irreversible or externally visible operation, when the requested scope changes, or when progress requires information only the user can provide. In all other cases, the model continues working and reports assumptions at turn end.
-
Structured completion — The model may only mark a task complete after the concrete request is satisfied, output format and constraints are met, and relevant verification has been attempted or reported unavailable.
// Example: Submitting a goal triggers the active-goal block
c.Submit("/goal fix the parser")
firstTurn := firstUserMessage(ag.Session().Messages)
// The active-goal block includes the task contract and pause policy
fmt.Println(firstTurn)
/*
<active-goal>
fix the parser
Goal mode: pursue this goal autonomously. Treat the user's goal as a task contract:
- Honor Context, Request, Output format, Constraints, and Checkpoint/Pause policy sections when present; otherwise infer a lightweight contract...
- 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...
...
</active-goal>
*/
Pause Policy Implementation via RecoveryPauseError
The pause policy is enforced through the RecoveryPauseError mechanism distributed across the engine's error handling and orchestration layers. When the controller detects conditions matching the pause criteria—such as impending irreversible modifications or scope changes—it throws a RecoveryPauseError defined in internal/agent/errors.go.
The turn orchestrator in internal/control/turn_orchestrator.go catches this error and classifies the turn outcome as TurnOutcomeRecoveryPaused, an enumeration defined in internal/event/event.go (lines 103-106). This consistent status reporting triggers the UI to display a pause notice (e.g., "⏸ Automatic retries paused…") and await explicit user input such as "continue" before resuming autonomous execution.
// Example: Triggering a pause when user clarification is required
if needUserInfo {
return &agent.RecoveryPauseError{Message: "need clarification from user"}
}
// The orchestrator catches the error and reports a paused outcome
if errors.As(err, &pauseErr) {
outcome = event.TurnOutcomeRecoveryPaused
}
This design ensures that autonomous execution never proceeds past critical decision points without explicit human oversight, while allowing uninterrupted progress through safe, reversible operations.
Verification Through Unit Testing
Reasonix guarantees contractual enforcement through comprehensive testing. The unit test TestActiveGoalBlockCarriesTaskContractAndPausePolicy in internal/control/goal_test.go (lines 57-66) verifies that every active-goal block automatically contains the contractual language and pause policy wording.
This test ensures that any goal entered into the system carries the complete task contract and pause rules by default, preventing inadvertent execution of irreversible actions without the protective pause mechanism.
Summary
- Task contract injection — Every goal submission automatically prepends contractual obligations to the model prompt via
goalTaskContractInstructionsininternal/control/input.go. - Risk-based pausing — The system halts execution via
RecoveryPauseErrorwhen facing irreversible actions, scope changes, or missing user information. - Deterministic outcomes —
TurnOutcomeRecoveryPausedprovides consistent status reporting across the orchestration layer and UI. - Tested enforcement — Unit tests verify that all active-goal blocks contain the mandatory contract and pause policy language.
Frequently Asked Questions
What triggers a pause in Reasonix autonomous execution?
Reasonix pauses when the model detects an irreversible operation, an externally visible change, a scope modification, or a need for user-specific information that cannot be inferred from context. These conditions trigger a RecoveryPauseError, converting the turn outcome to TurnOutcomeRecoveryPaused and suspending execution until the user provides guidance.
How does the task contract handle missing explicit constraints?
When users do not provide explicit Context, Request, Output format, Constraints, or Checkpoint/Pause policy sections, the model must infer a lightweight contract from the conversation history and workspace state. Crucially, the model must explicitly state any assumptions it makes when filling these gaps, ensuring transparency in autonomous decision-making.
What is the difference between TurnOutcomeRecoveryPaused and other outcomes?
TurnOutcomeRecoveryPaused specifically indicates that execution halted due to the pause policy detecting a risky or ambiguous condition requiring user input. Other outcomes might indicate successful completion, execution errors, or standard turn endings, but only TurnOutcomeRecoveryPaused invokes the UI pause notice and waits for explicit "continue" confirmation before proceeding.
How does Reasonix prevent execution of irreversible actions without consent?
The system embeds pause conditions directly into the active-goal block's task contract, instructing the model to throw a RecoveryPauseError before committing irreversible changes. The internal/control/turn_orchestrator.go layer intercepts these errors, stops autonomous execution, and requires explicit user confirmation through the UI before allowing the operation to proceed.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →