fix: external model name now recorded properly in responses
test: http cassettes added for improved integration tests refactor: generic name for the CLI agent
This commit is contained in:
@@ -3,8 +3,8 @@ Conversation Memory for AI-to-AI Multi-turn Discussions
|
||||
|
||||
This module provides conversation persistence and context reconstruction for
|
||||
stateless MCP (Model Context Protocol) environments. It enables multi-turn
|
||||
conversations between Claude and Gemini by storing conversation state in memory
|
||||
across independent request cycles.
|
||||
conversations between the agent and downstream models by storing conversation
|
||||
state in memory across independent request cycles.
|
||||
|
||||
CRITICAL ARCHITECTURAL REQUIREMENT:
|
||||
This conversation memory system is designed for PERSISTENT MCP SERVER PROCESSES.
|
||||
@@ -97,7 +97,7 @@ Collection Phase (Newest-First Priority):
|
||||
- Excludes: Turn 2, Turn 1 (oldest, dropped due to token limits)
|
||||
|
||||
Presentation Phase (Chronological Order):
|
||||
- LLM sees: "--- Turn 3 (Claude) ---", "--- Turn 4 (Gemini) ---", "--- Turn 5 (Claude) ---"
|
||||
- LLM sees: "--- Turn 3 (Agent) ---", "--- Turn 4 (Model) ---", "--- Turn 5 (Agent) ---"
|
||||
- Natural conversation flow maintained despite prioritizing recent context
|
||||
|
||||
This enables true AI-to-AI collaboration across the entire tool ecosystem with optimal
|
||||
@@ -152,7 +152,7 @@ class ConversationTurn(BaseModel):
|
||||
the content and metadata needed for cross-tool continuation.
|
||||
|
||||
Attributes:
|
||||
role: "user" (Claude) or "assistant" (Gemini/O3/etc)
|
||||
role: "user" (Agent request) or "assistant" (model response)
|
||||
content: The actual message content/response
|
||||
timestamp: ISO timestamp when this turn was created
|
||||
files: List of file paths referenced in this specific turn
|
||||
@@ -321,7 +321,7 @@ def add_turn(
|
||||
|
||||
Args:
|
||||
thread_id: UUID of the conversation thread
|
||||
role: "user" (Claude) or "assistant" (Gemini/O3/etc)
|
||||
role: "user" (Agent request) or "assistant" (model response)
|
||||
content: The actual message/response content
|
||||
files: Optional list of files referenced in this turn
|
||||
images: Optional list of images referenced in this turn
|
||||
@@ -707,7 +707,7 @@ def build_conversation_history(context: ThreadContext, model_context=None, read_
|
||||
|
||||
<turn_content>
|
||||
|
||||
--- Turn 2 (Gemini using analyze via google/gemini-2.5-flash) ---
|
||||
--- Turn 2 (gemini-2.5-flash using analyze via google) ---
|
||||
Files used in this turn: file3.py
|
||||
|
||||
<turn_content>
|
||||
@@ -921,7 +921,11 @@ def build_conversation_history(context: ThreadContext, model_context=None, read_
|
||||
for idx in range(len(all_turns) - 1, -1, -1):
|
||||
turn = all_turns[idx]
|
||||
turn_num = idx + 1
|
||||
role_label = "Claude" if turn.role == "user" else "Gemini"
|
||||
|
||||
if turn.role == "user":
|
||||
role_label = "Agent"
|
||||
else:
|
||||
role_label = turn.model_name or "Assistant"
|
||||
|
||||
# Build the complete turn content
|
||||
turn_parts = []
|
||||
@@ -932,8 +936,13 @@ def build_conversation_history(context: ThreadContext, model_context=None, read_
|
||||
turn_header += f" using {turn.tool_name}"
|
||||
|
||||
# Add model info if available
|
||||
if turn.model_provider and turn.model_name:
|
||||
turn_header += f" via {turn.model_provider}/{turn.model_name}"
|
||||
if turn.model_provider:
|
||||
provider_descriptor = turn.model_provider
|
||||
if turn.model_name and turn.model_name != role_label:
|
||||
provider_descriptor += f"/{turn.model_name}"
|
||||
turn_header += f" via {provider_descriptor}"
|
||||
elif turn.model_name and turn.model_name != role_label:
|
||||
turn_header += f" via {turn.model_name}"
|
||||
|
||||
turn_header += ") ---"
|
||||
turn_parts.append(turn_header)
|
||||
@@ -970,7 +979,7 @@ def build_conversation_history(context: ThreadContext, model_context=None, read_
|
||||
turn_entries.reverse()
|
||||
|
||||
# Add the turns in chronological order for natural LLM comprehension
|
||||
# The LLM will see: "--- Turn 1 (Claude) ---" followed by "--- Turn 2 (Gemini) ---" etc.
|
||||
# The LLM will see: "--- Turn 1 (Agent) ---" followed by "--- Turn 2 (Model) ---" etc.
|
||||
for _, turn_content in turn_entries:
|
||||
history_parts.append(turn_content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user