Skip to content

fix(sessions): reconcile pending input appends - #4906

Open
seanxuu wants to merge 14 commits into
openai:mainfrom
seanxuu:fix/issue-4775-pending-input-recovery
Open

fix(sessions): reconcile pending input appends#4906
seanxuu wants to merge 14 commits into
openai:mainfrom
seanxuu:fix/issue-4775-pending-input-recovery

Conversation

@seanxuu

@seanxuu seanxuu commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix pending-input Session appends so they use the existing fail-closed reconciliation checkpoint. A retry appends once after an atomic failure, recognizes a committed lost-ack append without duplicating it, consumes only the checkpoint-owned pending-input prefix, and preserves already-completed guardrail results.

The RunState schema is bumped to 1.18 for the new pending-input ownership metadata. Checkpoint restoration validates input items before Session I/O, and Conversations reconciliation uses the same persistence normalization as its stored batch.

Test plan

  • make typecheck
  • uv run pytest -q tests/test_run_state_pending_input.py tests/test_run_impl_resume_paths.py tests/test_run_state.py tests/test_run_state_compatibility_corpus.py (710 passed)
  • uv run ruff check src/agents/run_state.py src/agents/run_internal/session_persistence.py tests/test_run_state_pending_input.py
  • The full verification wrapper reached 9,426 passing tests. The remaining test failures require git init --initial-branch=main, which this host's Git does not support.

Issue number

Closes #4775

Checks

  • I've added new tests, if relevant
  • I've run the repository verification wrapper
  • I've confirmed applicable focused verification steps pass

@seanxuu
seanxuu force-pushed the fix/issue-4775-pending-input-recovery branch from 3d1d54d to e4606b5 Compare September 8, 2026 01:40
@seanxuu
seanxuu marked this pull request as ready for review September 8, 2026 01:50
@seanxuu
seanxuu force-pushed the fix/issue-4775-pending-input-recovery branch from e4606b5 to b928be7 Compare September 8, 2026 03:01
@seratch seratch assigned seratch and unassigned seratch Sep 8, 2026

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packaged compatibility assertion is now aligned, and both Linux packaged-contract checks pass. The runtime implementation and pending-input tests are unchanged, so the remaining requests still apply:

  • Initialize a fresh OpenAIConversationsSession before reading its session ID.
  • Account for Conversations API message normalization when comparing recovery fingerprints.
  • Accept SDK-generated local-shell replay items during pending-input deserialization.
  • Capture the streamed result's checkpoint after the expected exception, and add a controlled test proving that input appended during an in-flight session write survives recovery.

These are still needed before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f446681dc8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/run_state.py Outdated
Comment thread src/agents/run_internal/session_persistence.py Outdated
Comment thread src/agents/run_internal/session_persistence.py
@seanxuu

seanxuu commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all four requested follow-ups in commit 454d2215:

  • Fresh OpenAIConversationsSession instances now initialize through the zero-item read path before their session ID is checkpointed.
  • Lost-ack reconciliation canonicalizes Conversations API message defaults (including shorthand string content expanded to a single text part) while preserving required payload IDs such as item_reference.
  • Pending Session-write checkpoint deserialization accepts SDK-generated local_shell_call_output replay items through the dedicated local-shell payload validator.
  • Added a controlled streamed-failure regression test that appends input while the Session write is blocked, captures failed_result.to_state(), and verifies both inputs survive recovery exactly once.
    alidation: 189 focused tests passed; make typecheck passed (mypy and pyright).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 454d22155b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/run_state.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78784a32c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/run_internal/session_persistence.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 315b4bb3c1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/run_state.py Outdated
fscfede-beep

This comment was marked as off-topic.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c7106f231

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/run_state.py Outdated
fscfede-beep

This comment was marked as off-topic.

fscfede-beep

This comment was marked as off-topic.

@seanxuu
seanxuu requested a review from fscfede-beep September 8, 2026 06:40
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
@openai openai deleted a comment from fscfede-beep Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RunState pending input can be duplicated when a Session append loses acknowledgement

3 participants