Skip to content

add summary operation to codex-rs/core #1527

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
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

add summary operation to codex-rs/core #1527

wants to merge 8 commits into from

Conversation

aibrahim-oai
Copy link
Contributor

Add operation to summarize the context so far.

@aibrahim-oai aibrahim-oai requested a review from bolinfest July 11, 2025 02:38
@aibrahim-oai aibrahim-oai changed the title add summary operation add summary operation to codex-rs/core Jul 11, 2025
Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's mostly small stuff?


// Create a summarization request as user input
const SUMMARIZATION_PROMPT: &str = concat!(
"Please provide a summary of our conversation so far, highlighting key points, ",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would favor a raw string (r#) over concat!() here (unless you really want this to be one line of text?): https://doc.rust-lang.org/rust-by-example/std/str.html#literals-and-escapes

// Attempt to inject input into current task
if let Err(items) = sess.inject_input(summarization_prompt) {
// No current task, spawn a new one
let task = AgentTask::spawn(Arc::clone(sess), sub.id, items);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? I think this is the more canonical way to do it.

Suggested change
let task = AgentTask::spawn(Arc::clone(sess), sub.id, items);
let task = AgentTask::spawn(sess.clone(), sub.id, items);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it's done here:

let task = AgentTask::spawn(Arc::clone(sess), sub.id, items);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does what I suggested not work?


// Wait for session configured
loop {
let event = timeout(Duration::from_secs(5), codex.next_event())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using codex_wrapper.rs instead (and you can remove the loop):

pub async fn init_codex(config: Config) -> anyhow::Result<(Codex, Event, Arc<Notify>)> {

// }
let _sub_id = codex.submit(Op::SummarizeContext).await.unwrap();

// Should receive a TaskStarted event indicating a new AgentTask was spawned
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is duplicative with the message to your assert!(), so I would favor keeping the one in assert!() over this one.


#[tokio::test]
async fn test_summarize_context_injects_into_running_task() {
// Test that when a task IS running, SummarizeContext injects into the existing task
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, prefer doc comment.

// rather than spawning a new one. We shouldn't get another TaskStarted event
let result = timeout(Duration::from_millis(500), codex.next_event()).await;

// If we get an event, it should NOT be TaskStarted (since we're injecting into existing task)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this does not feel like a strong verification. Can we instead test for what we should get instead of one possible thing we shouldn't get?

@aibrahim-oai aibrahim-oai requested a review from bolinfest July 12, 2025 00:26
@bolinfest
Copy link
Collaborator

@aibrahim-oai can you please fix CI? seems like mostly warnings promoted to errors?

Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like my comments from the previous review haven't been addressed yet?

@aibrahim-oai aibrahim-oai requested a review from bolinfest July 12, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants