chore: track condeser metadata for llm completion (#7938)

This commit is contained in:
Xingyao Wang 2025-04-18 17:05:31 -04:00 committed by GitHub
parent f751f8ab37
commit 06fcf54475
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -51,6 +51,7 @@ class Condenser(ABC):
def __init__(self):
self._metadata_batch: dict[str, Any] = {}
self._llm_metadata: dict[str, Any] = {}
def add_metadata(self, key: str, value: Any) -> None:
"""Add information to the current metadata batch.
@ -100,6 +101,7 @@ class Condenser(ABC):
def condensed_history(self, state: State) -> View | Condensation:
"""Condense the state's history."""
self._llm_metadata = state.to_llm_metadata('condenser')
with self.metadata_batch(state):
return self.condense(state.view)

View File

@ -133,6 +133,7 @@ CURRENT_STATE: Last flip: Heads, Haiku count: 15/20"""
response = self.llm.completion(
messages=self.llm.format_messages_for_llm(messages),
extra_body={'metadata': self._llm_metadata},
)
summary = response.choices[0].message.content