mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Persist explicit user goal edits in model history (#49598)
## Why User goal edits and clears need to reach the model as user instructions, including when a thread is unloaded or history is being compacted. Automatic goal lifecycle updates must not supply user authorization. ## What changed - Add optional `origin` values of `user` and `automatic` to `thread/goal/set` and `thread/goal/clear`, and mark TUI goal requests as user actions. Omitted origins do not supply user authorization. - Persist explicit user objective, status, and clear instructions before changing goal state. Recording failures leave goal state unchanged. - Coordinate goal edits with thread resume, reload stored history under writer ownership, and preserve edits accepted after the compaction input snapshot. - Update generated protocol schemas and TypeScript and Python bindings. ## Testing Add coverage for user edits and clears on loaded and unloaded threads, concurrent path-based resume, exclusion of automatic goals from user instructions, preservation of edits during compaction, and recording failures that leave goal state unchanged. GitOrigin-RevId: d779d7c678a0c32a6ef76975dbe5b1400d1df245
This commit is contained in:
@@ -2522,6 +2522,7 @@ mod tests {
|
||||
let thread_goal_set = ClientRequest::ThreadGoalSet {
|
||||
request_id: request_id(),
|
||||
params: v2::ThreadGoalSetParams {
|
||||
origin: None,
|
||||
thread_id: "goal-thread".to_string(),
|
||||
objective: Some("ship it".to_string()),
|
||||
status: None,
|
||||
@@ -4440,6 +4441,7 @@ mod tests {
|
||||
let set_request = ClientRequest::ThreadGoalSet {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadGoalSetParams {
|
||||
origin: None,
|
||||
thread_id: "thr_123".to_string(),
|
||||
objective: Some("ship goal mode".to_string()),
|
||||
status: Some(v2::ThreadGoalStatus::Active),
|
||||
@@ -4455,6 +4457,7 @@ mod tests {
|
||||
let clear_request = ClientRequest::ThreadGoalClear {
|
||||
request_id: RequestId::Integer(3),
|
||||
params: v2::ThreadGoalClearParams {
|
||||
origin: None,
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -841,11 +841,24 @@ impl From<codex_protocol::protocol::ThreadGoal> for ThreadGoal {
|
||||
}
|
||||
}
|
||||
|
||||
/// Distinguishes explicit user actions from automatic goal lifecycle mutations.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadGoalMutationOrigin {
|
||||
User,
|
||||
Automatic,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadGoalSetParams {
|
||||
pub thread_id: String,
|
||||
/// Missing provenance does not supply user authorization.
|
||||
#[ts(optional = nullable)]
|
||||
pub origin: Option<ThreadGoalMutationOrigin>,
|
||||
#[ts(optional = nullable)]
|
||||
pub objective: Option<String>,
|
||||
#[ts(optional = nullable)]
|
||||
@@ -886,6 +899,9 @@ pub struct ThreadGoalGetResponse {
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadGoalClearParams {
|
||||
pub thread_id: String,
|
||||
/// Missing provenance does not supply user authorization.
|
||||
#[ts(optional = nullable)]
|
||||
pub origin: Option<ThreadGoalMutationOrigin>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
|
||||
Reference in New Issue
Block a user