Skip to content

fix(sessions): stop pre-warmed session bodies from loading empty - #370

Merged
lg2m merged 7 commits into
mainfrom
chore/remaining-pieces
Oct 20, 2026
Merged

lg2m merged 7 commits into
mainfrom
chore/remaining-pieces

Conversation

@lg2m

@lg2m lg2m commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

What changed for users

Old sessions no longer open empty. The TUI's startup snapshot fetches the focused session plus four pre-warmed sessions, and all five share one 6 MiB body budget. Each body was allowed up to 4,096 tool-call rows before the next body's messages were loaded, so one tool-heavy session used up the budget. The bodies after it came back with 0 messages and has_older_messages=true. The client installed them as warm-empty, so focusing one showed "Ask QQ to begin this session." and nothing was refetched.

  • load_snapshot now loads every body's transcript first and spends the remaining budget on tool-call tails afterwards.
  • The per-body tool-call cap drops from 4,096 to 64, the window the client keeps (MAX_RECENT_TOOL_CALLS). Older calls are still flagged with has_older_tool_calls.
  • The client now keeps a budget-starved body (no messages, has_older_messages) cold rather than installing it as empty, so the session is fetched when it's focused.

Replaying the real store (from a copy): before, 3 of 12 bodies had messages; after, 12 of 12, in a 3.1 MB response.

cargo xtask check refuses a branch that silently reverts merged base changes. If the branch restores a file to its pre-merge state after main changed it (the git reset --soft origin/main mistake that hit #365), the check fails and names the files.

Verification

  • New tests prewarmed_bodies_keep_their_messages_when_an_earlier_body_has_many_tool_results (core) and a_body_the_snapshot_budget_starved_stays_cold_instead_of_empty (client) both fail without the fix and pass with it.
  • a_branch_that_restores_files_the_base_changed_is_refused passes. Run against the old bad refactor(agents): simplify agent guidance, approvals, and overload retry #365 commit, the guard flags the reverted auth/session files.
  • one_durable_run_continues_across_the_internal_tool_budget now expects the 64-call snapshot window plus has_older_tool_calls.
  • cargo xtask check passes.

Not in this PR

  • revision_notices_across_reactive_checkpoint_overflow_reopen_in_order: already fixed on main by test(core): let the goal-audit fixture's held preparation observe shutdown cancellation #366.
  • Turning the reviewer off by default under auto: dropped. It needs a protocol bump, and the store shows the reviewer auto-approved hundreds of calls. The long waits came from human approvals, so turning it off would add waits.
  • Freezing goals/governance features: that's a product decision, not code work.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T05:12:55.645384Z a1f74a7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: d05e61d01a

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread xtask/src/check.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed both findings in 3c44e16 with regression coverage. All 167 qq-client/xtask tests pass. cargo xtask check passed fmt, lint, and clippy, then hit the local 600-second execution timeout during the broader test phase (no completed report).

@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: 3c44e16673

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-client/src/state.rs Resolved
Comment thread xtask/src/check.rs Resolved
@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Status: initial findings were fixed in 3c44e16 (with replies on both threads). The three follow-up findings are now fixed locally: focused cold bodies trigger an isolated refetch, the protocol budget-order docs are updated, and the stale-tree guard compares modes plus object IDs. Regression tests failed before and pass after; all 519 TUI/xtask tests pass (1 skipped). Full check passed fmt/lint/clippy and is finishing broader tests. I am committing these fixes and rebasing onto main next, then will request another @codex review.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

lg2m added 4 commits October 19, 2026 21:28
One snapshot request shares a 6 MiB body budget across the focused session and the pre-warmed ones. Each body spent it on up to 4,096 tool calls (the client keeps 64) before the next body loaded its messages, so on a real store 9 of 12 pre-warmed sessions came back with no messages. The TUI cached those as empty and showed "Ask QQ to begin this session." without refetching.

- Snapshots load every transcript first, then tool calls from what remains.
- A body carries at most 64 tool calls, the window the client keeps.
- The client keeps a body that has no messages but older history unloaded, so focusing it fetches its own body.
@lg2m
lg2m force-pushed the chore/remaining-pieces branch from 3c44e16 to 7a9e531 Compare October 20, 2026 04:29
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

All three follow-up findings fixed in 7a9e531; rebased onto latest origin/main without conflicts and pushed with explicit force-with-lease. 519 TUI/xtask tests pass (1 skipped). Full local gate passed fmt/lint/clippy; broader test phase still running. Please review the latest head.

@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: 7a9e531b3a

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread xtask/src/check.rs Resolved
Comment thread xtask/src/check.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed all three latest findings in 5364ff9. 561 client/TUI/xtask tests pass (1 skipped); fmt/lint/clippy pass. The broader local gate did not complete successfully (its test build log ended abruptly); relying on fresh CI for full validation. The earlier compaction timeout passes its focused rerun. Please review latest head.

@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: 5364ff9eee

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread xtask/src/check.rs Resolved
Comment thread crates/qq-client/src/state.rs Resolved
@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Latest review status: both findings are fixed locally. Intentional rollbacks can be acknowledged with a committed, exact-path QQ-Allow-Revert: <path> trailer (other paths remain guarded). All truncated shared bodies now stay cold for an isolated fetch, including partial rather than zero-row starvation; isolated responses preserve available rows. Targeted regression checks pass. The single full gate is running: fmt/lint/clippy passed, tests underway. I will push and request the next review after it finishes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Both latest findings fixed and pushed in e5a175b. 561 client/TUI/xtask tests pass (1 skipped); targeted regressions, fmt and changed-crate clippy pass. The full gate passed fmt/lint/clippy and its entire test phase (477.5s), but rejected the final evidence stamp because a follow-up warm-body regression fix changed the worktree while it ran. That follow-up passed the 561-test suite and clippy separately. Fresh CI will verify the exact pushed tree.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: e5a175b3a5

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m

lg2m commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Codex review loop complete on e5a175b: Codex reports “Didn’t find any major issues,” summary shows no findings/unresolved findings, and the bot added 👍 to this PR at 05:07:57Z. All review findings have fix replies. Branch was rebased onto main. CI for this exact head is still running: https://github.com/retsu-AI/qq/actions/runs/39372881641

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m
lg2m merged commit bda6668 into main Oct 20, 2026
6 checks passed
@lg2m
lg2m deleted the chore/remaining-pieces branch October 20, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant