Rebase onto upstream (a4d95fd)
#12
@@ -48,20 +48,20 @@ class Session:
|
||||
# Everything else (timestamp, tools_used, etc.) is internal metadata.
|
||||
_API_FIELDS = {"role", "content", "tool_calls", "tool_call_id", "name", "reasoning_content"}
|
||||
|
||||
def get_history(self, max_messages: int = 50) -> list[dict[str, Any]]:
|
||||
def get_history(self) -> list[dict[str, Any]]:
|
||||
"""
|
||||
Get message history for LLM context.
|
||||
Get full message history for LLM context.
|
||||
|
||||
Args:
|
||||
max_messages: Maximum messages to return.
|
||||
The server-side context editing API (clear_tool_uses_20250919) handles
|
||||
trimming old tool chains safely at token thresholds, so we send the full
|
||||
history and let the server decide what to drop.
|
||||
|
||||
Returns:
|
||||
List of messages in LLM format (API-relevant fields only).
|
||||
"""
|
||||
recent = self.messages[-max_messages:] if len(self.messages) > max_messages else self.messages
|
||||
return [
|
||||
{k: v for k, v in m.items() if k in self._API_FIELDS and v is not None}
|
||||
for m in recent
|
||||
for m in self.messages
|
||||
]
|
||||
|
||||
def clear(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user