mirror of
https://github.com/openai/codex.git
synced 2026-04-29 02:41:12 +03:00
fix: single transaction for dyn tools injection (#10614)
This commit is contained in:
@@ -419,6 +419,7 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
return Ok(());
|
||||
}
|
||||
let thread_id = thread_id.to_string();
|
||||
let mut tx = self.pool.begin().await?;
|
||||
for (idx, tool) in tools.iter().enumerate() {
|
||||
let position = i64::try_from(idx).unwrap_or(i64::MAX);
|
||||
let input_schema = serde_json::to_string(&tool.input_schema)?;
|
||||
@@ -439,9 +440,10 @@ ON CONFLICT(thread_id, position) DO NOTHING
|
||||
.bind(tool.name.as_str())
|
||||
.bind(tool.description.as_str())
|
||||
.bind(input_schema)
|
||||
.execute(self.pool.as_ref())
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
tx.commit().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user