code-mode: use client cell ids and linear observations

This commit is contained in:
Channing Conger
2026-06-22 08:49:51 +00:00
parent 28536e0bb5
commit e7f4fc2005
18 changed files with 349 additions and 161 deletions
+1
View File
@@ -25,6 +25,7 @@ pub use runtime::CreateCellRequest;
pub use runtime::DEFAULT_EXEC_YIELD_TIME_MS;
pub use runtime::DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL;
pub use runtime::DEFAULT_WAIT_YIELD_TIME_MS;
pub use runtime::ObservationGeneration;
pub use runtime::ObserveOutcome;
pub use runtime::ObserveRequest;
pub use runtime::RuntimeResponse;
+25 -2
View File
@@ -14,7 +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 cell_id: CellId,
pub tool_call_id: String,
pub enabled_tools: Vec<ToolDefinition>,
pub source: String,
@@ -22,11 +22,34 @@ pub struct CreateCellRequest {
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ObserveRequest {
pub idempotency_key: String,
pub cell_id: CellId,
pub generation: ObservationGeneration,
pub yield_time_ms: u64,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[serde(transparent)]
pub struct ObservationGeneration(u64);
impl ObservationGeneration {
pub const INITIAL: Self = Self(0);
pub const fn new(value: u64) -> Self {
Self(value)
}
pub const fn get(self) -> u64 {
self.0
}
pub const fn next(self) -> Option<Self> {
match self.0.checked_add(1) {
Some(value) => Some(Self(value)),
None => None,
}
}
}
/// A valid result of observing a cell.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(tag = "type")]
@@ -34,7 +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(),
cell_id: CellId::new("cell-a7".to_string()),
tool_call_id: "response-call-7".to_string(),
enabled_tools: vec![
ToolDefinition {
@@ -62,7 +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",
"cell_id": "cell-a7",
"tool_call_id": "response-call-7",
"enabled_tools": [
{
@@ -91,13 +91,13 @@ 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()),
generation: ObservationGeneration::new(/*value*/ 3),
yield_time_ms: 250,
},
json!({
"idempotency_key": "thread-3:wait-call-2",
"cell_id": "cell-a7",
"generation": 3,
"yield_time_ms": 250,
}),
);