Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
Showing only changes of commit 993c05efdc - Show all commits
+6 -6
View File
@@ -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: