Skip to content

Codex /compact completes then thread enters systemError in HAPI #982

Description

@qwertlooker

What version of HAPI is running?

0.20.2

What platform is your computer?

Linux x86_64 / WSL2

OS: Linux x86_64 / WSL2
Codex CLI: 0.142.4

What issue are you seeing?

In a HAPI + Codex session, /compact appears to complete, but the conversation becomes unusable immediately afterwards: the next user message fails with Task failed: Codex thread entered systemError; retrying same conversation.

Important detail: new Codex sessions and normal messages work. The failure is specifically tied to the Codex compact control path. If I do not compact, other sessions continue normally.

Observed UI flow:

/compact
Compaction started
Compaction completed

<next user message>
Task failed: Codex thread entered systemError; retrying same conversation (1/3)

Local evidence from Codex rollout/logs shows the compact RPC and completion happened before the thread failure:

app-server request: thread/compact/start
...
type=compacted
payload.type=context_compacted

I also saw log patterns around the failed continuation such as:

incremental request failed, items didn't match

This looks like the HAPI Codex remote /compact path successfully calls thread/compact/start, but after the compaction boundary the next turn resumes/sends against a stale or invalid Codex thread state. Once Codex reports thread-level systemError, HAPI appears to treat the Codex thread as invalid and the current HAPI session loses the usable Codex context.

What steps can reproduce the bug?

  1. Start a Codex session from HAPI.
  2. Use the session normally for a while.
  3. Send /compact from the HAPI web UI.
  4. Wait until HAPI shows Compaction completed.
  5. Send any follow-up user message.
  6. HAPI reports Task failed: Codex thread entered systemError; retrying same conversation, and the session cannot continue reliably.

What is the expected behavior?

After /compact completes, HAPI should refresh/resume the compacted Codex app-server thread state and the next message should continue in the same conversation with the compacted context.

If Codex returns a transient compact/system error, HAPI should either:

  • preserve enough state to retry/resume the same Codex thread when possible; or
  • surface an explicit recovery action instead of silently starting/invalidating a fresh thread and losing context.

Additional information

Host-specific identifiers and local paths are intentionally omitted/redacted.

Related HAPI issues/code paths:

Related upstream Codex compaction reports:

This may be a compatibility issue between HAPI's /compact handling and newer Codex compaction behavior in codex-cli 0.142.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions