Feature Request: Add TaskCompleted Hook Event

Open 💬 4 comments Opened Apr 10, 2026 by bergo-tools
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Description

Currently, Codex provides several hook events such as PreToolUse, PostToolUse, UserPromptSubmit, and Stop. However, there is no explicit hook that represents the completion of a full task (i.e., when the agent has finished executing a user request end-to-end).

I would like to propose introducing a new hook event: TaskCompleted.

---

Motivation

While existing hooks cover turn-level and tool-level lifecycle events, they are still somewhat fragmented when building higher-level integrations.

A TaskCompleted hook would provide a clear and reliable signal that:

The agent has finished executing the entire task

No further actions or tool calls are expected

The final output is ready for downstream processing

This is especially useful for:

Logging and analytics pipelines

Triggering post-task automation (e.g., notifications, CI steps)

Persisting results or summaries

Integrating with external orchestration systems

Measuring task-level performance and success rates

---

Proposed Behavior

The TaskCompleted hook should fire exactly once per task

It should run after the final response is generated

It should include structured metadata, such as:

Final response content

Task duration

Tools used (if applicable)

Status (success / failure / interrupted)

Example (conceptual):

{
"event": "TaskCompleted",
"data": {
"final_output": "...",
"duration_ms": 12345,
"tools_used": ["local_shell", "file_write"],
"status": "success"
}
}

---

Why Existing Hooks Are Not Enough

Stop operates at turn scope, not full task scope

PostToolUse is too granular and tool-specific

There is no single event that reliably signals task-level completion

This makes it harder to build robust integrations without additional inference or custom patching.

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #16484

Powered by Codex Action

Frulfump · 4 months ago

Isn't there already a hook for SessionStart so it would make more sense to call it SessionEnd when looking for that functionality?

oxysoft · 3 months ago

Indexed this hook ticket in the umbrella tracker: #21753

Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.

khughitt · 24 days ago

A concrete status-integration use case: external renderers may distinguish done from error, but the Stop hook in codex-cli 0.146.0 provides no terminal outcome. Mapping every Stop to done can therefore represent a failed turn as a success.

PostToolUseFailure would not fully solve this: a failed tool can be recovered within a successful turn, and a turn can fail without a corresponding tool failure.

The app-server’s turn/completed notification already carries a final status. Exposing an equivalent structured completed | failed | interrupted outcome through TaskCompleted, or adding it to Stop, would let hook consumers represent the terminal state without parsing unstable transcript data.