Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions acp_adapter/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ def _persist(self, state: SessionState) -> None:
tool_name=msg.get("tool_name") or msg.get("name"),
tool_calls=msg.get("tool_calls"),
tool_call_id=msg.get("tool_call_id"),
reasoning=msg.get("reasoning"),
reasoning_details=msg.get("reasoning_details"),
codex_reasoning_items=msg.get("codex_reasoning_items"),
)
except Exception:
logger.warning("Failed to persist ACP session %s", state.session_id, exc_info=True)
Expand Down
33 changes: 33 additions & 0 deletions tests/acp/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,39 @@ def test_tool_calls_persisted(self, manager):
assert restored.history[0].get("tool_calls") is not None
assert restored.history[1].get("tool_call_id") == "tc_1"

def test_assistant_reasoning_fields_persisted(self, manager):
"""ACP session restore should preserve assistant reasoning context."""
state = manager.create_session()
state.history.append({
"role": "assistant",
"content": "hello",
"reasoning": "step-by-step",
"reasoning_details": [
{"type": "thinking", "thinking": "first thought"},
],
"codex_reasoning_items": [
{"type": "reasoning", "id": "rs_123", "encrypted_content": "enc_blob"},
],
})
manager.save_session(state.session_id)

with manager._lock:
del manager._sessions[state.session_id]

restored = manager.get_session(state.session_id)
assert restored is not None
assert restored.history == [{
"role": "assistant",
"content": "hello",
"reasoning": "step-by-step",
"reasoning_details": [
{"type": "thinking", "thinking": "first thought"},
],
"codex_reasoning_items": [
{"type": "reasoning", "id": "rs_123", "encrypted_content": "enc_blob"},
],
}]

def test_restore_preserves_persisted_provider_snapshot(self, tmp_path, monkeypatch):
"""Restored ACP sessions should keep their original runtime provider."""
runtime_choice = {"provider": "anthropic"}
Expand Down
Loading