fix: align agent memory write signature with the pinned EE ref

EE #812 made write_to_memory take allow_truncation and return the number
of dropped messages, ahead of its OSS companion #10928. The EE ref bump
in #11197 pulled it in, so build_ee and check_ee_full fail to compile.
Port the OSS signature half of #10928; the single caller keeps today's
truncating behavior.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-09-29 17:52:44 +02:00
co-authored by Claude Opus 5.5
parent 6064aecdec
commit efdb53a242
3 changed files with 37 additions and 9 deletions
@@ -2059,6 +2059,7 @@ pub async fn run_agent(
*memory_id,
step_id,
&messages_to_persist,
true,
)
.await
{
+16 -4
View File
@@ -30,16 +30,21 @@ pub async fn read_from_db(
}
}
/// Write AI agent memory to database with size checking and truncation
/// Write AI agent memory to database with size checking and truncation.
///
/// Returns how many of the oldest messages were dropped to fit, so the step can say so
/// on the run: from the flow's side a truncation is invisible, the agent simply having
/// forgotten the start of its conversation by the next one.
pub async fn write_to_db(
db: &DB,
workspace_id: &str,
conversation_id: Uuid,
step_id: &str,
messages: &[OpenAIMessage],
) -> Result<(), Error> {
allow_truncation: bool,
) -> Result<usize, Error> {
if messages.is_empty() {
return Ok(());
return Ok(0);
}
// Serialize messages and check size
@@ -49,6 +54,13 @@ pub async fn write_to_db(
// Truncate if necessary
if size_bytes > MAX_MEMORY_SIZE_BYTES {
// Compaction owns its exchange boundaries, including after an object-store failure.
if !allow_truncation {
return Err(Error::ExecutionErr(format!(
"Memory exceeds database capacity ({} > {} bytes); existing memory was not updated",
size_bytes, MAX_MEMORY_SIZE_BYTES
)));
}
tracing::warn!(
"Memory size ({} bytes) exceeds limit ({} bytes) for workspace={} conversation={} step={}. Truncating messages. Use S3 storage in workspace settings to store full conversation history.",
size_bytes,
@@ -78,7 +90,7 @@ pub async fn write_to_db(
.execute(db)
.await?;
Ok(())
Ok(messages.len() - messages_to_store.len())
}
/// Delete all memory for a conversation from database
+20 -5
View File
@@ -30,14 +30,29 @@ pub async fn write_to_memory(
conversation_id: Uuid,
step_id: &str,
messages: &[OpenAIMessage],
) -> anyhow::Result<()> {
allow_truncation: bool,
) -> anyhow::Result<usize> {
if messages.is_empty() {
return Ok(());
return Ok(0);
}
memory_common::write_to_db(db, workspace_id, conversation_id, step_id, messages)
.await
.map_err(|e| anyhow::anyhow!("Database write failed: {e:?}"))
memory_common::write_to_db(
db,
workspace_id,
conversation_id,
step_id,
messages,
allow_truncation,
)
.await
.map_err(|e| anyhow::anyhow!("Database write failed: {e:?}"))
}
/// How many bytes a persisted memory can hold, `None` where nothing bounds it.
/// In OSS: always the database limit
#[cfg(not(all(feature = "private", feature = "enterprise")))]
pub async fn memory_storage_capacity_bytes() -> Option<usize> {
Some(memory_common::MAX_MEMORY_SIZE_BYTES)
}
/// Delete all memory for a conversation from storage