mirror of
https://github.com/openai/codex.git
synced 2026-04-30 09:26:44 +00:00
Merge origin/main into rhan/surface-updates and resolve guardian tests conflict
This commit is contained in:
@@ -205,7 +205,12 @@ async fn fetch_backfill(
|
||||
filter: &LogFilter,
|
||||
backfill: usize,
|
||||
) -> anyhow::Result<Vec<LogRow>> {
|
||||
let query = to_log_query(filter, Some(backfill), None, true);
|
||||
let query = to_log_query(
|
||||
filter,
|
||||
Some(backfill),
|
||||
/*after_id*/ None,
|
||||
/*descending*/ true,
|
||||
);
|
||||
runtime
|
||||
.query_logs(&query)
|
||||
.await
|
||||
@@ -217,7 +222,12 @@ async fn fetch_new_rows(
|
||||
filter: &LogFilter,
|
||||
last_id: i64,
|
||||
) -> anyhow::Result<Vec<LogRow>> {
|
||||
let query = to_log_query(filter, None, Some(last_id), false);
|
||||
let query = to_log_query(
|
||||
filter,
|
||||
/*limit*/ None,
|
||||
Some(last_id),
|
||||
/*descending*/ false,
|
||||
);
|
||||
runtime
|
||||
.query_logs(&query)
|
||||
.await
|
||||
@@ -225,7 +235,9 @@ async fn fetch_new_rows(
|
||||
}
|
||||
|
||||
async fn fetch_max_id(runtime: &StateRuntime, filter: &LogFilter) -> anyhow::Result<i64> {
|
||||
let query = to_log_query(filter, None, None, false);
|
||||
let query = to_log_query(
|
||||
filter, /*limit*/ None, /*after_id*/ None, /*descending*/ false,
|
||||
);
|
||||
runtime
|
||||
.max_log_id(&query)
|
||||
.await
|
||||
|
||||
@@ -30,7 +30,8 @@ impl StateRuntime {
|
||||
/// stage-1 (`memory_stage1`) and phase-2 (`memory_consolidate_global`)
|
||||
/// memory pipelines.
|
||||
pub async fn clear_memory_data(&self) -> anyhow::Result<()> {
|
||||
self.clear_memory_data_inner(false).await
|
||||
self.clear_memory_data_inner(/*disable_existing_threads*/ false)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Resets persisted memory state for a clean-slate local start.
|
||||
@@ -39,7 +40,8 @@ impl StateRuntime {
|
||||
/// jobs, this disables memory generation for all existing threads so
|
||||
/// historical rollouts are not immediately picked up again.
|
||||
pub async fn reset_memory_data_for_fresh_start(&self) -> anyhow::Result<()> {
|
||||
self.clear_memory_data_inner(true).await
|
||||
self.clear_memory_data_inner(/*disable_existing_threads*/ true)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn clear_memory_data_inner(&self, disable_existing_threads: bool) -> anyhow::Result<()> {
|
||||
@@ -193,12 +195,12 @@ LEFT JOIN jobs
|
||||
);
|
||||
push_thread_filters(
|
||||
&mut builder,
|
||||
false,
|
||||
/*archived_only*/ false,
|
||||
allowed_sources,
|
||||
None,
|
||||
None,
|
||||
/*model_providers*/ None,
|
||||
/*anchor*/ None,
|
||||
SortKey::UpdatedAt,
|
||||
None,
|
||||
/*search_term*/ None,
|
||||
);
|
||||
builder.push(" AND threads.memory_mode = 'enabled'");
|
||||
builder
|
||||
|
||||
@@ -50,7 +50,7 @@ WHERE id = ?
|
||||
) -> anyhow::Result<Option<Vec<DynamicToolSpec>>> {
|
||||
let rows = sqlx::query(
|
||||
r#"
|
||||
SELECT name, description, input_schema
|
||||
SELECT name, description, input_schema, defer_loading
|
||||
FROM thread_dynamic_tools
|
||||
WHERE thread_id = ?
|
||||
ORDER BY position ASC
|
||||
@@ -70,6 +70,7 @@ ORDER BY position ASC
|
||||
name: row.try_get("name")?,
|
||||
description: row.try_get("description")?,
|
||||
input_schema,
|
||||
defer_loading: row.try_get("defer_loading")?,
|
||||
});
|
||||
}
|
||||
Ok(Some(tools))
|
||||
@@ -188,7 +189,7 @@ FROM threads
|
||||
model_providers,
|
||||
anchor,
|
||||
sort_key,
|
||||
None,
|
||||
/*search_term*/ None,
|
||||
);
|
||||
push_thread_order_and_limit(&mut builder, sort_key, limit);
|
||||
|
||||
@@ -203,7 +204,7 @@ FROM threads
|
||||
|
||||
/// Insert or replace thread metadata directly.
|
||||
pub async fn upsert_thread(&self, metadata: &crate::ThreadMetadata) -> anyhow::Result<()> {
|
||||
self.upsert_thread_with_creation_memory_mode(metadata, None)
|
||||
self.upsert_thread_with_creation_memory_mode(metadata, /*creation_memory_mode*/ None)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -425,8 +426,9 @@ INSERT INTO thread_dynamic_tools (
|
||||
position,
|
||||
name,
|
||||
description,
|
||||
input_schema
|
||||
) VALUES (?, ?, ?, ?, ?)
|
||||
input_schema,
|
||||
defer_loading
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(thread_id, position) DO NOTHING
|
||||
"#,
|
||||
)
|
||||
@@ -435,6 +437,7 @@ ON CONFLICT(thread_id, position) DO NOTHING
|
||||
.bind(tool.name.as_str())
|
||||
.bind(tool.description.as_str())
|
||||
.bind(input_schema)
|
||||
.bind(tool.defer_loading)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user