Repository navigation
Feat/issue 297/conversation session - #325
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive, well-covered by tests, and introduce the session abstraction with safe history ownership while keeping Ollama details isolated.
Pull request overview
Introduces a new in-memory conversation session abstraction to own ordered chat history and updates the CLI + Ollama client to use the shared canonical message/role types.
Changes:
- Added
internal/conversation.Sessionwith append operations and history copy/alias safety. - Refactored
internal/ollama.Client.Chatto accept/returnconversation.Message, mapping to Ollama’s wire format internally. - Updated CLI flow and tests to build requests via a session and pass immutable history into chat calls.
File summaries
| File | Description |
|---|---|
| main.go | Builds the initial user turn using a conversation.Session and passes session history to chat. |
| main_test.go | Updates run() tests to assert the new conversation.Message history shape. |
| internal/ollama/client.go | Removes exported Ollama-specific message types; converts conversation.Message to/from request/response JSON. |
| internal/ollama/client_test.go | Adjusts tests to validate wire-format payloads and returned conversation.Message. |
| internal/conversation/session.go | Adds the new session type, canonical roles/messages, and safe Messages() cloning. |
| internal/conversation/session_test.go | Adds table-driven coverage for initialization, append ordering, and copy/alias safety. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
103
to
+107
| if decodeErr != nil || strings.TrimSpace(apiError.Error) == "" { | ||
| return Message{}, fmt.Errorf("Ollama chat request failed: %s", response.Status) | ||
| return conversation.Message{}, fmt.Errorf("ollama chat request failed: %s", response.Status) | ||
| } | ||
|
|
||
| return Message{}, fmt.Errorf("Ollama chat request failed: %s: %s", response.Status, apiError.Error) | ||
| return conversation.Message{}, fmt.Errorf("ollama chat request failed: %s: %s", response.Status, apiError.Error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #297