Skip to content

Commit

Permalink
fix: record the external memory summary inside of the context viewer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacker authored Dec 23, 2024
1 parent c8f5dc3 commit e09fd52
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions letta/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ def get_context_window(self) -> ContextWindowOverview:
num_archival_memory=agent_manager_passage_size,
num_recall_memory=message_manager_size,
num_tokens_external_memory_summary=num_tokens_external_memory_summary,
external_memory_summary=external_memory_summary,
# top-level information
context_window_size_max=self.agent_state.llm_config.context_window,
context_window_size_current=num_tokens_used_total,
Expand Down
3 changes: 3 additions & 0 deletions letta/schemas/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class ContextWindowOverview(BaseModel):
num_tokens_external_memory_summary: int = Field(
..., description="The number of tokens in the external memory summary (archival + recall metadata)."
)
external_memory_summary: str = Field(
..., description="The metadata summary of the external memory sources (archival + recall metadata)."
)

# context window breakdown (in tokens)
# this should all add up to context_window_size_current
Expand Down
1 change: 1 addition & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ def test_get_context_window_overview(server: SyncServer, user, agent_id):
assert overview.num_archival_memory is not None
assert overview.num_recall_memory is not None
assert overview.num_tokens_external_memory_summary is not None
assert overview.external_memory_summary is not None
assert overview.num_tokens_system is not None
assert overview.system_prompt is not None
assert overview.num_tokens_core_memory is not None
Expand Down

0 comments on commit e09fd52

Please sign in to comment.