mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
code-mode: make create and observe retry-safe
This commit is contained in:
@@ -14,6 +14,7 @@ pub const DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL: usize = 10_000;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct CreateCellRequest {
|
||||
pub idempotency_key: String,
|
||||
pub tool_call_id: String,
|
||||
pub enabled_tools: Vec<ToolDefinition>,
|
||||
pub source: String,
|
||||
@@ -21,6 +22,7 @@ pub struct CreateCellRequest {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct ObserveRequest {
|
||||
pub idempotency_key: String,
|
||||
pub cell_id: CellId,
|
||||
pub yield_time_ms: u64,
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ fn image(image_url: &str, detail: Option<ImageDetail>) -> FunctionCallOutputCont
|
||||
#[test]
|
||||
fn requests_round_trip_with_exact_tool_and_namespace_fields() {
|
||||
let create = CreateCellRequest {
|
||||
idempotency_key: "thread-3:response-call-7".to_string(),
|
||||
tool_call_id: "response-call-7".to_string(),
|
||||
enabled_tools: vec![
|
||||
ToolDefinition {
|
||||
@@ -61,6 +62,7 @@ fn requests_round_trip_with_exact_tool_and_namespace_fields() {
|
||||
assert_json_round_trip(
|
||||
&create,
|
||||
json!({
|
||||
"idempotency_key": "thread-3:response-call-7",
|
||||
"tool_call_id": "response-call-7",
|
||||
"enabled_tools": [
|
||||
{
|
||||
@@ -89,10 +91,15 @@ fn requests_round_trip_with_exact_tool_and_namespace_fields() {
|
||||
|
||||
assert_json_round_trip(
|
||||
&ObserveRequest {
|
||||
idempotency_key: "thread-3:wait-call-2".to_string(),
|
||||
cell_id: CellId::new("cell-a7".to_string()),
|
||||
yield_time_ms: 250,
|
||||
},
|
||||
json!({"cell_id": "cell-a7", "yield_time_ms": 250}),
|
||||
json!({
|
||||
"idempotency_key": "thread-3:wait-call-2",
|
||||
"cell_id": "cell-a7",
|
||||
"yield_time_ms": 250,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user