-
Notifications
You must be signed in to change notification settings - Fork 360
fix(channel): stop re-summarising worker results that were already relayed #333
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
Merged
Merged
Changes from all commits
Commits
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,10 @@ pub struct CompletedItem { | |||||||||
| pub description: String, | ||||||||||
| pub completed_at: DateTime<Utc>, | ||||||||||
| pub result_summary: String, | ||||||||||
| /// Whether this item's result has been relayed to the user via retrigger. | ||||||||||
| /// Once relayed, the result summary is excluded from the status block to | ||||||||||
| /// prevent the LLM from re-summarising stale results. | ||||||||||
| pub relayed: bool, | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Status of an active link conversation. | ||||||||||
|
|
@@ -94,6 +98,7 @@ impl StatusBlock { | |||||||||
| description: worker.task, | ||||||||||
| completed_at: Utc::now(), | ||||||||||
| result_summary: result.clone(), | ||||||||||
| relayed: false, | ||||||||||
| }); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -120,19 +125,42 @@ impl StatusBlock { | |||||||||
| description: branch.description, | ||||||||||
| completed_at: Utc::now(), | ||||||||||
| result_summary: conclusion.clone(), | ||||||||||
| relayed: false, | ||||||||||
| }); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Keep only last 10 completed items | ||||||||||
| if self.completed_items.len() > 10 { | ||||||||||
| self.completed_items.remove(0); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| ProcessEvent::AgentMessageSent { to_agent_id, .. } => { | ||||||||||
| self.track_link_conversation(to_agent_id.as_ref()); | ||||||||||
| } | ||||||||||
| _ => {} | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Prune completed items: drop relayed items older than 5 minutes, | ||||||||||
| // then cap at 10 to bound status block size. | ||||||||||
| self.prune_completed_items(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Mark completed items as relayed so the status block stops showing | ||||||||||
| /// their full result summaries. Called after a retrigger turn succeeds. | ||||||||||
| pub fn mark_relayed(&mut self, process_ids: &[String]) { | ||||||||||
| for item in &mut self.completed_items { | ||||||||||
| if process_ids.contains(&item.id) { | ||||||||||
| item.relayed = true; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Remove stale completed items: relayed items older than 5 minutes are | ||||||||||
| /// dropped entirely, then total count is capped at 10. | ||||||||||
| fn prune_completed_items(&mut self) { | ||||||||||
| let cutoff = Utc::now() - chrono::Duration::minutes(5); | ||||||||||
| self.completed_items | ||||||||||
| .retain(|item| !(item.relayed && item.completed_at < cutoff)); | ||||||||||
|
|
||||||||||
| // Hard cap: keep the 10 most recent. | ||||||||||
| while self.completed_items.len() > 10 { | ||||||||||
|
Contributor
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.
Suggested change
|
||||||||||
| self.completed_items.remove(0); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Add a new active branch. | ||||||||||
|
|
@@ -246,10 +274,19 @@ impl StatusBlock { | |||||||||
| output.push('\n'); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Recently completed | ||||||||||
| if !self.completed_items.is_empty() { | ||||||||||
| // Recently completed — only show items not yet relayed to the user. | ||||||||||
| // Relayed items already appeared in conversation via the retrigger flow; | ||||||||||
| // keeping their full summaries here causes the LLM to re-summarise them. | ||||||||||
| let unrelayed: Vec<_> = self | ||||||||||
| .completed_items | ||||||||||
| .iter() | ||||||||||
| .rev() | ||||||||||
| .filter(|item| !item.relayed) | ||||||||||
| .take(5) | ||||||||||
| .collect(); | ||||||||||
| if !unrelayed.is_empty() { | ||||||||||
| output.push_str("## Recently Completed\n"); | ||||||||||
| for item in self.completed_items.iter().rev().take(5) { | ||||||||||
| for item in &unrelayed { | ||||||||||
| let type_str = match item.item_type { | ||||||||||
| CompletedItemType::Branch => "branch", | ||||||||||
| CompletedItemType::Worker => "worker", | ||||||||||
|
|
||||||||||
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.
Worth not swallowing parse errors here: if the metadata ever changes shape, this silently stops marking items as relayed (and the bot regresses).