Files
hermes-agent/tests
Teknium 9a19cd6cf3 feat: persist reasoning across gateway session turns (schema v6)
Add reasoning TEXT, reasoning_details TEXT, and codex_reasoning_items
TEXT columns to the messages table (schema v5->v6). This preserves
assistant reasoning chains across gateway session reloads so all
provider-specific reasoning formats survive the round-trip.

Three reasoning formats are now persisted:
- reasoning: plain text (DeepSeek, Qwen, Moonshot, Novita, OpenRouter)
- reasoning_details: structured array (OpenRouter multi-turn continuity)
- codex_reasoning_items: encrypted blobs (OpenAI Codex Responses API)

Previously, all three existed in-memory during a single session but
were lost on gateway reload.

Changes:
- hermes_state.py: schema v6 migration, append_message() accepts all
  three fields, get_messages_as_conversation() restores them on
  assistant messages
- run_agent.py: _flush_messages_to_session_db() passes all reasoning
  fields through for assistant messages
- gateway/run.py: agent_history builder preserves reasoning fields
  on non-tool-calling assistant messages
- gateway/session.py: append_to_transcript() and rewrite_transcript()
  pass all reasoning fields to the DB
- Tests: 5 new tests for round-trip persistence

Verified against:
- OpenAI Codex direct (codex_reasoning_items round-trip: 868 enc chars)
- OpenRouter -> Anthropic, Google, DeepSeek, Meta, Qwen, Mistral
- Anthropic adapter (strips extra fields by construction)
- Codex Responses API path (replays codex_reasoning_items correctly)
2026-03-25 09:21:51 -07:00
..