Skip to content

[IDE Extension][Goal/Context] Repeated premature task_complete, stale goal state, and ~16.9M token consumption in a single unfinished long-running task #44829

Open

Description

@N9K32

What version of the IDE extension are you using?

Runtime metadata recorded in the rollout: originator: codex_vscode source: vscode codex-cli: 0.154.0-alpha.6.1 model: gpt-6-astra reasoning_effort: high

What subscription do you have?

This is the plan_type recorded in the rollout telemetry.

Which IDE are you using?

Visual Studio Code

What platform is your computer?

Windows 11 Pro x64

What issue are you seeing?

Runtime metadata from the affected rollout:

originator: codex_vscode
source: vscode
cli_version: 0.154.0-alpha.6.1
model: gpt-6-astra
reasoning_effort: high
plan_type: prolite

The raw rollout contains private repository data, so I am not attaching the unredacted JSONL publicly.

The following information has intentionally been removed from this issue:

repository name and URL
local username
workspace paths
private file and directory names
private source code
asset names
application/domain names
database filenames
private identifiers
commit hashes
session/thread identifiers
project-specific prompts and implementation details

If maintainers need the original session telemetry, I can provide the corresponding private feedback/session data through an appropriate non-public diagnostic channel.

The main issue I would like investigated is the relationship between:

task completion gating
goal-state synchronization
interruption/paused-state recovery
PreToolUse directive state
context compaction
execution-frontier preservation

because the observed behavior caused five premature task terminations and approximately 16.9 million thread tokens in a single unfinished task.

What steps can reproduce the bug?

Codex repeatedly reports task_complete while the active goal is objectively unfinished, even when its own immediately preceding response explicitly states that required work, validation, or acceptance criteria remain incomplete.

This occurred in one long-running VS Code Codex session with an explicitly persistent goal and explicit instructions not to stop on recoverable tool/runtime failures.

The private repository name, local paths, source code, asset names, domain-specific identifiers, and other project-specific information have all been removed from this report.

Summary

In a single rollout I observed:

task_started:        9
task_complete:       5
turn_aborted:        3
context_compacted:   2
thread_goal_updated: 1
exec tool calls:     173
rollout records:     1360

There were five premature **task_complete** events.

At least the first two occurred before any context compaction, so this does not appear to be explainable solely as post-compaction memory degradation.

The overall failure pattern was:

stale previous directive reaches PreToolUse
        ↓
recoverable command failure
        ↓
task_complete although required work was not performed
        ↓
user manually resumes the same goal
        ↓
agent creates a persistent goal
        ↓
user explicitly corrects scope/order
        ↓
stored goal does not fully follow the latest correction
        ↓
goal becomes paused after interruption
        ↓
explicit continuation does not visibly reactivate/update goal state
        ↓
context compaction
        ↓
previously rejected approach reappears
        ↓
intermediate cleanup is treated as task completion
        ↓
another context compaction
        ↓
an empty runtime/test state is treated as a reason to terminate
        ↓
user manually resumes again
        ↓
agent immediately acknowledges that stopping was wrong
        ↓
agent continues with an executable next step that had already been available

Failure 1: stale PreToolUse directive blocked the current instruction

The current user instruction explicitly required use of a particular local tool/workflow.

A PreToolUse hook instead injected an older conflicting directive similar to:

Command blocked by PreToolUse hook:
User directive: Do not reopen the prohibited analysis source or its artifacts: <REDACTED>.
Use the established facts and continue ...

The important issue is not only that one command was blocked.

The failure was recoverable and alternate valid next steps existed.

Instead of resolving the conflict or continuing through another valid path, Codex reported that the requested operation had not been performed and then emitted task_complete.

Effectively:

required operation not performed
→ task_complete

Failure 2: Codex explicitly reported failed acceptance conditions and still completed the task

During another termination, Codex's own immediately preceding output stated that required validation had not passed and required results were unavailable.

The state was effectively:

validation failed
required work still missing
required result data unavailable
→ task_complete

This is internally contradictory.

Completion did not require an external user judgment to determine that the task was unfinished; Codex itself had already stated that it was unfinished.

Failure 3: latest user correction was not preserved as the authoritative goal

During the session, the user explicitly corrected an incorrect scope expansion.

Generalized, the correction was:

Create canonical artifact A first.
Only validate the subset recorded in A afterward.
Do not build a separate whole-project analyzer.
Continue the same persistent goal.

Codex acknowledged the correction and removed the incorrectly created helper.

However, later goal telemetry continued to contain parts of the superseded direction.

The observed state became effectively:

latest user directive != stored goal objective/status

After an interruption, the stored goal was also observable as:

status = paused

The user subsequently issued explicit continuation instructions multiple times, but no corresponding visible goal-state update restored the goal to an active/current version containing the latest correction.

Failure 4: an explicitly rejected approach was recreated later

The user had explicitly rejected a separate analyzer/validation path.

Codex:

  1. acknowledged this,
  2. removed the helper,
  3. continued working,
  4. later recreated the same class of separate analyzer,
  5. eventually reread the relevant architecture,
  6. recognized that the analyzer did not validate the actual production path,
  7. removed it again.

Generalized:

incorrect scope expansion
→ user correction
→ agent acknowledges correction
→ invalid helper removed
→ long-running execution/context evolution
→ same rejected approach reappears
→ agent later discovers it is invalid
→ helper removed again

This suggests that the latest user correction was not being maintained as durable authoritative execution state.

Failure 5: context compaction was followed by another premature completion

After the first automatic context compaction, Codex updated only an intermediate schema/state.

Required runtime/result data was still effectively:

required validation/runtime results = 0

Nevertheless, Codex emitted another task_complete.

When the user manually resumed the session, Codex immediately acknowledged, in substance:

The task is not finished.
Stopping after only updating the intermediate state was my mistake.
I will continue the remaining runtime validation.

This demonstrates that the preceding termination was not caused by a hard blocker.

Failure 6: another premature completion occurred after the second compaction

After the second context compaction, Codex removed an incorrectly created intermediate helper.

It then emitted another task_complete.

However, removal of an invalid intermediate implementation was not an acceptance criterion for the main goal.

Effectively:

remove incorrect intermediate implementation
→ main goal still unfinished
→ task_complete

Failure 7: an unprepared runtime fixture was interpreted as completion

Later, Codex inspected the runtime and found that the relevant test/runtime objects had not yet been loaded.

That state meant:

runtime/test fixture has not been prepared yet

The executable next step was to load the known input and continue validation.

Instead, Codex effectively reasoned:

nothing relevant is currently loaded
→ no successful validation exists
→ task_complete

After the user manually resumed the task, Codex immediately acknowledged that stopping at the empty runtime state had been wrong and proceeded to load the required input.

Therefore, an executable next step existed at the time task_complete was emitted.

Five premature task_complete events

# State when task_complete was emitted Why the goal was still unfinished
1 Current command blocked by stale hook Requested operation had not been executed
2 Agent reported validation failure Agent itself stated required work/results were missing
3 Only intermediate schema/state updated Required runtime/result rows were still absent
4 Incorrect helper removed Main goal acceptance criteria were still unverified
5 Runtime fixture was empty Known executable next step existed and worked after manual resume

The recurring issue is that Codex appears to treat the completion of a local substep, cleanup operation, failure report, or observation as permission to terminate the entire persistent goal.

Token usage / resource impact

This single rollout lasted approximately:

2026-09-11T11:02:59.009Z
to
2026-09-11T13:56:53.969Z

Approximately 2 hours 54 minutes.

Final thread_token_usage:

input_tokens:            16,641,965
cached_input_tokens:     16,007,424
uncached_input_tokens:      634,541
output_tokens:              251,538
reasoning_output_tokens:    163,720
total_tokens:            16,893,503

reasoning_output_tokens is reported as a separate telemetry field but was not added again to total_tokens.

total_tokens already equals:

input_tokens + output_tokens

Compaction token usage

First context compaction:

input_tokens:          199,550
cached_input_tokens:   188,928
output_tokens:           5,891
total_tokens:          205,441

Second context compaction:

input_tokens:          184,811
cached_input_tokens:   174,080
output_tokens:           8,180
total_tokens:          192,991

Combined:

compaction input:          384,361
compaction cached input:   363,008
compaction uncached input:  21,353
compaction output:          14,071
compaction total:          398,432

The final regular cumulative token_count.info.total_token_usage was:

input_tokens:            16,257,604
cached_input_tokens:     15,644,416
output_tokens:              237,467
reasoning_output_tokens:    163,720
total_tokens:            16,495,071

The difference between full thread usage and regular cumulative token usage is:

16,893,503
-16,495,071
-----------
   398,432

This exactly matches:

205,441 + 192,991 = 398,432

the two recorded compaction responses.

Therefore the rollout telemetry can be interpreted as:

16,893,503 = full thread usage including compaction responses
16,495,071 = regular cumulative token_count
   398,432 = separately recorded compaction usage

I did not sum cumulative token-count snapshots together.

Rate-limit impact

At the beginning of the observed session:

primary.used_percent = 73
window_minutes = 10080

Near the end:

primary.used_percent = 83
window_minutes = 10080

This is a reported increase from 73% to 83% within the same 7-day window.

Because this telemetry is rounded and the rollout alone cannot prove that no other usage occurred during that period, I am not claiming that the entire 10 percentage-point increase was caused exclusively by this session.

The relevant fact is that the failed long-running thread itself recorded approximately 16.9 million tokens.

What is the expected behavior?

The session shows multiple interacting state/lifecycle failures:

  1. stale directive propagation into PreToolUse
  2. completio
    n gating failure
  3. latest-user-directive / stored-goal desynchronization
  4. paused/interrupted goal recovery failure
  5. context-compaction state fidelity problems
  6. recreation of an explicitly rejected implementation direction

Importantly, the first two premature task_complete events occurred before any context compaction.

Therefore the entire issue cannot be explained only as:

context compaction made the model forget

Also, after several premature terminations, a manual user continuation immediately caused Codex to:

admit the previous termination was incorrect, and
continue with an already-available executable next step.

That behavior strongly suggests a completion/frontier-state problem rather than an actual inability to proceed.

Additional information

No response

Activity

  1. added
    extension
    on Sep 11, 2026
  2. added
    bug
    model-behavior
    session
    context
    hooks
    rate-limits
    on Sep 11, 2026
  3. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor
  4. bhooshanvarma commented on Sep 15, 2026

    @bhooshanvarma

    The stale PreToolUse directive and the premature completion decision appear to share one missing contract: the action is being evaluated against state that is no longer authoritative. I would bind each consequential transition—tool execution and task completion—to the exact goal revision, latest user directive, and acceptance-state fields it relied on. Immediately before the transition, re-read those dependencies; if any changed or cannot be verified, stop and recompute instead of applying the earlier decision.

    That would not fix the lifecycle state machine by itself, but it creates a deterministic testable boundary: capture revision A, apply user correction B, and prove that a transition carrying A cannot execute or mark the task complete.

    I maintain FreshCtx at Hyperwise. It is a local, no-telemetry guard for this evidence-drift pattern. If useful, I can share a minimal fixture shaped around your PreToolUse and task-completion sequence to see whether the dependency model maps cleanly.

  5. RongNianXin commented on Oct 6, 2026

    @RongNianXin

    Adding a potentially related Windows desktop case, with an important distinction between observations and hypotheses.

    On October 6, I submitted a long Chinese implementation Goal through the desktop Goal UI twice. Both submissions appeared in the conversation as:

    Read the Codex goal objective file at <redacted attachment path>/goal-objective.md before continuing.

    The transcript shows a successful file-read command in each run. Its untruncated output contained the full Chinese specification, including implementation, automated tests, applicable human/device acceptance, and an explicit prohibition on treating reading/planning as completion. Despite this, the agent stated that reading the file satisfied the only explicit objective, did no implementation, and ended with a claim that the Goal had been changed to complete.

    The displayed duration was about 26 seconds per run; the agent reported approximately 21 and 25 seconds respectively. The thread API records approximately 31 and 28 seconds for the turns. These are different measurements, not evidence of a fixed timeout. A separate earlier planning-only completion incident is not included in this comparison.

    Evidence limits: the thread API available to me exposes the file reads and responses but does not show the underlying get_goal/update_goal calls or persisted Goal objective/state for these two runs. Therefore, I cannot independently verify the claimed status transition or establish that the short visible message replaced the durable objective. The exact affected app build/model and any conversion threshold remain unverified. I also cannot attribute this to compaction, a token limit, or a quota gate from these observations.

    Hypothesis for investigation: the externalized objective-file path and the durable completion contract may become inconsistent, or the model may incorrectly treat the file-reading wrapper as the whole objective even after reading the implementation requirements. This is a candidate explanation, not a confirmed cause or proof that prompt length is the trigger.

    Would it be useful to compare the submitted objective, externalized file contents, persisted Goal objective, effective continuation prompt, and any completion-tool event for this path? A regression test could verify that reading an externalized objective does not satisfy its implementation/test acceptance criteria. The official Goals guide says completion should be supported by concrete evidence: https://developers.openai.com/cookbook/examples/codex/using_goals_in_codex

    A proposed mitigation is to keep the desired outcome and completion criteria directly in a short Goal, explicitly reference the detailed specification as the authorized execution contract, and inspect the actual stored objective before proceeding. This mitigation has not yet been validated against our incident.

  6. aldi949 commented on Oct 7, 2026

    @aldi949

    @N9K32 the part that stands out is that task_complete happened even when the worker already knew validation had failed and required results were still missing.
    That’s exactly the boundary I’m testing: the worker’s status should never override external evidence.
    I built a small prototype that checks a fixed acceptance contract independently of the worker. Your failed-validation case looks like a very good adversarial test for it.
    If you’re willing, try breaking it with a sanitized version of that case:
    https://github.com/aldi949/truth-firewall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcontextextensionhooksmodel-behaviorrate-limitssession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions