codex - 💡(How to fix) Fix Feature Request: Add TaskCompleted Hook Event [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17333Fetched 2026-04-11 06:17:31
View on GitHub
Comments
2
Participants
3
Timeline
8
Reactions
1
Timeline (top)
labeled ×3commented ×2cross-referenced ×1marked_as_duplicate ×1

Fix Action

Fix / Workaround

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

RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

Introduce a new hook event, TaskCompleted, to provide a clear signal of task completion, including metadata such as final response content, task duration, and status.

Guidance

  • Define the TaskCompleted hook to fire exactly once per task, after the final response is generated, to ensure reliable signaling of task completion.
  • Include structured metadata in the TaskCompleted hook, such as final response content, task duration, tools used, and status, to support downstream processing and integration.
  • Evaluate the existing hook events, such as Stop and PostToolUse, to determine how they can be used in conjunction with the new TaskCompleted hook to build more robust integrations.
  • Consider the use cases for the TaskCompleted hook, including logging and analytics pipelines, post-task automation, and external orchestration systems, to ensure the hook meets the required functionality.

Example

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

Notes

The introduction of the TaskCompleted hook requires careful consideration of the existing hook events and their relationships to ensure seamless integration and avoid potential conflicts.

Recommendation

Apply workaround by introducing the proposed TaskCompleted hook event, as it provides a clear and reliable signal of task completion, enabling more robust integrations and supporting various use cases.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING