-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Show goal-started threads in resume lists #21489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
etraut-openai
wants to merge
3
commits into
main
Choose a base branch
from
etraut/goal-resume-metadata-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−5
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,9 @@ pub fn apply_rollout_item( | |
| pub fn rollout_item_affects_thread_metadata(item: &RolloutItem) -> bool { | ||
| match item { | ||
| RolloutItem::SessionMeta(_) | RolloutItem::TurnContext(_) => true, | ||
| RolloutItem::EventMsg(EventMsg::TokenCount(_) | EventMsg::UserMessage(_)) => true, | ||
| RolloutItem::EventMsg( | ||
| EventMsg::TokenCount(_) | EventMsg::UserMessage(_) | EventMsg::ThreadGoalUpdated(_), | ||
| ) => true, | ||
| RolloutItem::EventMsg(_) | RolloutItem::ResponseItem(_) | RolloutItem::Compacted(_) => { | ||
| false | ||
| } | ||
|
|
@@ -96,6 +98,14 @@ fn apply_event_msg(metadata: &mut ThreadMetadata, event: &EventMsg) { | |
| } | ||
| } | ||
| } | ||
| EventMsg::ThreadGoalUpdated(event) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this have an impact on the title? If a reaul user message arrives after the goal, it will now look like a distinct title and start shwoing up as thread name |
||
| if metadata.first_user_message.is_none() { | ||
| let objective = event.goal.objective.trim(); | ||
| if !objective.is_empty() { | ||
| metadata.first_user_message = Some(objective.to_string()); | ||
| } | ||
| } | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
@@ -136,6 +146,7 @@ pub(crate) fn enum_to_string<T: Serialize>(value: &T) -> String { | |
| #[cfg(test)] | ||
| mod tests { | ||
| use super::apply_rollout_item; | ||
| use super::rollout_item_affects_thread_metadata; | ||
| use crate::model::ThreadMetadata; | ||
| use chrono::DateTime; | ||
| use chrono::Utc; | ||
|
|
@@ -151,6 +162,9 @@ mod tests { | |
| use codex_protocol::protocol::SessionMeta; | ||
| use codex_protocol::protocol::SessionMetaLine; | ||
| use codex_protocol::protocol::SessionSource; | ||
| use codex_protocol::protocol::ThreadGoal; | ||
| use codex_protocol::protocol::ThreadGoalStatus; | ||
| use codex_protocol::protocol::ThreadGoalUpdatedEvent; | ||
| use codex_protocol::protocol::TurnContextItem; | ||
| use codex_protocol::protocol::USER_MESSAGE_BEGIN; | ||
| use codex_protocol::protocol::UserMessageEvent; | ||
|
|
@@ -231,6 +245,34 @@ mod tests { | |
| assert_eq!(metadata.title, ""); | ||
| } | ||
|
|
||
| #[test] | ||
| fn event_msg_thread_goal_sets_first_user_message_preview() { | ||
| let mut metadata = metadata_for_test(); | ||
| let item = RolloutItem::EventMsg(EventMsg::ThreadGoalUpdated(ThreadGoalUpdatedEvent { | ||
| thread_id: metadata.id, | ||
| turn_id: None, | ||
| goal: ThreadGoal { | ||
| thread_id: metadata.id, | ||
| objective: "optimize the benchmark".to_string(), | ||
| status: ThreadGoalStatus::Active, | ||
| token_budget: None, | ||
| tokens_used: 0, | ||
| time_used_seconds: 0, | ||
| created_at: 1, | ||
| updated_at: 1, | ||
| }, | ||
| })); | ||
|
|
||
| assert!(rollout_item_affects_thread_metadata(&item)); | ||
| apply_rollout_item(&mut metadata, &item, "test-provider"); | ||
|
|
||
| assert_eq!( | ||
| metadata.first_user_message.as_deref(), | ||
| Some("optimize the benchmark") | ||
| ); | ||
| assert_eq!(metadata.title, ""); | ||
| } | ||
|
|
||
| #[test] | ||
| fn turn_context_does_not_override_session_cwd() { | ||
| let mut metadata = metadata_for_test(); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, this won't backfill previous sessions but it's fine I guess