Skip to content

feat: conversation history threading in ModelCompletionRequest#6

Merged
broomva merged 1 commit intomainfrom
feature/conversation-history
Apr 5, 2026
Merged

feat: conversation history threading in ModelCompletionRequest#6
broomva merged 1 commit intomainfrom
feature/conversation-history

Conversation

@broomva
Copy link
Copy Markdown
Owner

@broomva broomva commented Apr 5, 2026

Adds ConversationTurn type and build_conversation_history() to KernelRuntime. Fixes multi-turn memory loss.

Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Model completion requests now carry conversation history, enabling the system to maintain and leverage context from prior user and assistant turns within sessions when communicating with model providers.

…tion_history

Add conversation_history field to ModelCompletionRequest so providers
receive multi-turn context. KernelRuntime::build_conversation_history()
reads the event journal and reconstructs user/assistant turns from
DeliberationProposed, Message, TextDelta, and RunFinished events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
broomva added a commit to broomva/arcan that referenced this pull request Apr 5, 2026
… adapter

Thread prior conversation turns (from aiOS ConversationTurn) into
ChatMessage array sent to the LLM. Inserts history between system
prompt and current objective.

Depends on: broomva/aiOS#6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request extends the protocol to include conversation history tracking. A new ConversationTurn type is introduced and re-exported from the crate root. The ModelCompletionRequest now carries a conversation_history field populated by a new runtime method that reconstructs prior user and assistant turns from persisted events.

Changes

Cohort / File(s) Summary
Protocol Types
crates/aios-protocol/src/lib.rs, crates/aios-protocol/src/ports.rs
Added ConversationTurn struct with role and content fields. Extended ModelCompletionRequest with conversation_history: Vec<ConversationTurn> field (serialized with defaults, omitted when empty). Re-exported ConversationTurn from crate root.
Runtime Implementation
crates/aios-runtime/src/lib.rs
Added build_conversation_history() async helper that reads up to 10,000 events from the store, extracts user turns from deliberation summaries and assistant text from messages/deltas, aggregates them into conversation turns (capped at 50 most recent), and passes the result into ModelCompletionRequest during tick_on_branch processing.

Sequence Diagram(s)

sequenceDiagram
    participant Runtime as KernelRuntime
    participant EventStore as Event Store
    participant Provider as Model Provider
    
    Runtime->>Runtime: tick_on_branch(session_id, branch_id)
    Runtime->>EventStore: read_events(session_id, branch_id, seq: 0, limit: 10000)
    EventStore-->>Runtime: events[]
    Runtime->>Runtime: build_conversation_history()
    Note over Runtime: Extract user turns from<br/>DeliberationProposed<br/>Extract assistant text from<br/>Message & TextDelta<br/>Aggregate into turns<br/>Cap at 50 most recent
    Runtime->>Runtime: Create ModelCompletionRequest<br/>with conversation_history
    Runtime->>Provider: complete(request)
    Provider-->>Runtime: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops with delight at conversation history unbounded,
Events from the past now faithfully rounded,
User and assistant turns dance in a Vec,
Fifty turns deep—what a glorious tech!
The model now remembers our every word's sound, 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding conversation history threading to ModelCompletionRequest. It is specific, concise, and reflects the primary objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/conversation-history

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@broomva broomva merged commit e09e3e8 into main Apr 5, 2026
0 of 3 checks passed
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