mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08: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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let thread_id = thread_id.to_string();
|
let thread_id = thread_id.to_string();
|
||||||
|
let mut tx = self.pool.begin().await?;
|
||||||
for (idx, tool) in tools.iter().enumerate() {
|
for (idx, tool) in tools.iter().enumerate() {
|
||||||
let position = i64::try_from(idx).unwrap_or(i64::MAX);
|
let position = i64::try_from(idx).unwrap_or(i64::MAX);
|
||||||
let input_schema = serde_json::to_string(&tool.input_schema)?;
|
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.name.as_str())
|
||||||
.bind(tool.description.as_str())
|
.bind(tool.description.as_str())
|
||||||
.bind(input_schema)
|
.bind(input_schema)
|
||||||
.execute(self.pool.as_ref())
|
.execute(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
tx.commit().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user