Problem
Recent sanitized Codewith logs show gpt-5.6-sol remote compaction using model_context_window_tokens=258400 while failing single-pass compact requests carry roughly 1.75-2.78 MB of model-visible history. PR #245 preserves history when overflow occurs, but it intentionally does not implement staged recovery.
Expected
Use authoritative model context metadata and compact oversized histories in bounded, provenance-preserving stages.
Acceptance
- Correct known current OpenAI model context-window metadata without changing unrelated provider caps.
- Budget the serialized request including instructions, tools, and history.
- Summarize bounded chunks before final compaction.
- Preserve unsummarized history and checkpoint state on every failure.
- Do not loop after deterministic overflow.
- Return a typed, actionable recovery result.
- Add large-history, resume, model-switch, cached-input, and tool-output regressions.
Related PR: #245
Related Todos: e6164e35, 5f509275, b1ce3ef0, aaa695d2
Problem
Recent sanitized Codewith logs show gpt-5.6-sol remote compaction using model_context_window_tokens=258400 while failing single-pass compact requests carry roughly 1.75-2.78 MB of model-visible history. PR #245 preserves history when overflow occurs, but it intentionally does not implement staged recovery.
Expected
Use authoritative model context metadata and compact oversized histories in bounded, provenance-preserving stages.
Acceptance
Related PR: #245
Related Todos: e6164e35, 5f509275, b1ce3ef0, aaa695d2