﻿# Interrupting a Codex turn without losing task ownership

Understand Codex turn interruption as a lifecycle operation, including its relation to task ownership, already changed files and the next user instruction.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/learn-codex-interrupt-lifecycle/
Language: en

A user can discover that a coding task needs a different direction while an agent is working. Codex app-server exposes turn interruption as an explicit operation. Handling that operation well means retaining the difference between requesting a stop, observing completion and deciding what work should happen next.

## Address the active turn explicitly

The interruption request identifies the thread and turn. This prevents a generic stop button from ambiguously targeting whichever conversation the interface happens to show later. The following illustrative payload describes the request shape; concrete identifiers must come from the active runtime objects. The response to this protocol request and the eventual turn status play different roles.

```json
{"id":"stop_request","method":"turn/interrupt","params":{"threadId":"thr_example","turnId":"turn_example"}}
```

## Wait for the lifecycle result

Sending the request tells the client that an interrupt was attempted. The client should continue processing the turn’s terminal notification rather than erase its activity record immediately. An application may display a stopping state during that interval. This describes interface design around the documented operation; it does not imply a particular cancellation latency or a guarantee about every tool’s external effects.

## Inspect what already changed

Imagine a refactor interrupted after a utility file was edited but before tests ran. The working tree now contains a real candidate change. Conversation cancellation does not itself determine whether that file should be kept. Inspect the diff and the latest user instruction together. The task can then continue from the present artifact or deliberately restore an earlier state through the repository’s normal controls.

## Reconcile state before continuing

A client can keep a small transition record to make the handoff explicit. Its purpose is to preserve facts rather than infer that an interrupted task failed in every respect. Some artifacts may be useful, some may be incomplete, and the next request can decide how to use them.

| Observed state | What the client knows | Appropriate next record |
| --- | --- | --- |
| Interrupt sent | A stop was requested | Keep the active turn associated with the request. |
| Terminal turn event | The turn reached a terminal status | Store that status against the interrupted turn. |
| Existing file change | A prior tool operation changed an artifact | Inspect the current diff before deciding to keep or revert it. |
| New user direction | The desired task has changed | Begin or steer work using the documented lifecycle and current artifacts. |

## Keep steering distinct from a new task

The app-server documents steering active work as well as starting a new turn. Choose the operation that matches the actual lifecycle and desired continuity. A correction that refines the same objective differs from abandoning it for unrelated work. A clear application model can preserve that distinction through interruption, making the final history explain why work stopped and which request subsequently owned the remaining change.

## Documentation and further study

- [Codex App Server](https://learn.chatgpt.com/docs/app-server).

- [Codex as a platform: build on the open agent harness](https://developers.openai.com/blog/codex-as-a-platform).

- [Non-interactive mode](https://learn.chatgpt.com/docs/non-interactive-mode).

Related engineering guides: [Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [Choose a local AI stack: desktop chat, shared UI or coding agent](/journal/local-ai-app-stack-selection/).
