Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(call): improve call title prompt and remove Untitled Call (#2937)
Will Hutchinson0cf6f09a91dd
diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rsindex af4820cfe8..c3234113a1 100644--- a/rust/cloud-storage/call/src/domain/ports.rs+++ b/rust/cloud-storage/call/src/domain/ports.rs@@ -301,14 +301,19 @@ pub trait CallSummarizer: Send + Sync + 'static {transcript: Vec<CallRecordTranscriptSegment>,) -> impl Future<Output = Result<String, Self::Err>> + Send;- /// Produce a short (typically 3–6 word) display name for the call from- /// its already-generated summary. Used by the auto-name flow only when- /// the call has no user-supplied `custom_name` yet.+ /// Produce a short display name for the call from its already-generated+ /// summary. Used by the auto-name flow only when the call has no+ /// user-supplied `custom_name` yet.+ ///+ /// Returns `Ok(None)` when the summary has no substantive content+ /// (silence, test call, accidental recording) so the caller can leave+ /// the existing `custom_name` untouched rather than persisting a+ /// generic placeholder.fn generate_call_name(&self,call_id: &Uuid,summary: &str,- ) -> impl Future<Output = Result<String, Self::Err>> + Send;+ ) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;}/// RTC client port for interacting with the real-time communication service (e.g., LiveKit).diff --git a/rust/cloud-storage/call/src/domain/service.rs b/rust/cloud-storage/call/src/domain/service.rsindex aa9edd4aa4..30ad9c4359 100644--- a/rust/cloud-storage/call/src/domain/service.rs+++ b/rust/cloud-storage/call/src/domain/service.rs@@ -999,7 +999,7 @@ impl<// effort — naming failures must not fail summarization.if record.custom_name.is_none() {match summarizer.generate_call_name(call_id, &summary).await {- Ok(name) => {+ Ok(Some(name)) => {if let Err(e) = self.repo.set_custom_name_if_null(call_id, &name).await {tracing::error!(error=?e, %call_id,@@ -1007,6 +1007,12 @@ impl<);}}+ Ok(None) => {+ tracing::info!(+ %call_id,+ "ai call naming returned no title; leaving name unset"+ );+ }Err(e) => {tracing::error!(error=?e, %call_id,@@ -1076,7 +1082,7 @@ impl<if record.custom_name.is_none() {match summarizer.generate_call_name(&call_id, &summary).await {- Ok(name) => {+ Ok(Some(name)) => {if let Err(e) = repo.set_custom_name_if_null(&call_id, &name).await {tracing::error!(error=?e, %call_id,@@ -1084,6 +1090,12 @@ impl<);}}+ Ok(None) => {+ tracing::info!(+ %call_id,+ "ai call naming returned no title; leaving name unset"+ );+ }Err(e) => {tracing::error!(error=?e, %call_id,@@ -1139,7 +1151,7 @@ impl CallSummarizer for NoopCallSummarizer {&self,_call_id: &Uuid,_summary: &str,- ) -> Result<String, Self::Err> {+ ) -> Result<Option<String>, Self::Err> {unreachable!("NoopCallSummarizer::generate_call_name invoked; it exists only as a type placeholder when the optional summarizer is None")diff --git a/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rs b/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rsindex 6d036fefde..dadbcdbca3 100644--- a/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rs+++ b/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rs@@ -38,11 +38,35 @@ Rules:/// System prompt for naming a call from its summary. Kept tight so the model/// returns a bare title instead of a sentence.const CALL_NAME_SYSTEM_PROMPT: &str = "\-You write short titles for recorded calls based on their summary. \-Output a single title — 3 to 6 words, Title Case, no punctuation, no \-quotes, no preamble, no sign-off. The title should reflect the main \-topic of the call; if the summary is empty or uninformative, respond \-with `Untitled Call`.";+You generate short titles for recorded calls from a written summary of the \+call. The title is shown in a list of past calls, so it must be specific \+enough to distinguish one call from another at a glance.++Output requirements:+- A single title, 4 to 8 words, in Title Case (capitalize every word except \+ articles, prepositions, and conjunctions of 3 letters or fewer).+- No surrounding quotes, no trailing punctuation, no preamble, no sign-off.+- Internal punctuation (colons, hyphens, ampersands, apostrophes) is allowed \+ when it improves readability.+- Prefer concrete topics and proper nouns drawn from the summary — people, \+ companies, projects, products — over generic words like `Meeting`, \+ `Discussion`, or `Call`.+- If the summary indicates the call had no substantive content (silence, \+ test call, accidental recording, empty transcript), output exactly: \+ UNTITLED_CALL++Examples:+Summary: `Alex and Priya reviewed Q3 marketing spend and agreed to cut paid \+search by 20% next quarter.` → `Q3 Marketing Spend Review`+Summary: `Standup with the platform team. Blocked on the Postgres upgrade; \+Sam will follow up with infra.` → `Platform Standup: Postgres Upgrade Blocker`+Summary: `Intro call between Jordan (Macro) and Lee (Acme) about a possible \+SSO integration.` → `Macro & Acme SSO Intro Call`+Summary: `No speech detected in the transcript.` → `UNTITLED_CALL`";++/// Sentinel the model is asked to emit when the summary has no substantive+/// content. Mapped to `None` so the caller leaves the existing name untouched.+const UNTITLED_CALL_SENTINEL: &str = "UNTITLED_CALL";/// Maximum characters of summary text we send to the naming model. The/// summary is already concise; this is a safety cap so a runaway summary@@ -96,10 +120,14 @@ impl CallSummarizer for AiCallSummarizer {}#[tracing::instrument(skip(self, summary), fields(summary_len = summary.len()), err)]- async fn generate_call_name(&self, call_id: &Uuid, summary: &str) -> Result<String, Self::Err> {+ async fn generate_call_name(+ &self,+ call_id: &Uuid,+ summary: &str,+ ) -> Result<Option<String>, Self::Err> {let trimmed_summary = summary.trim();if trimmed_summary.is_empty() {- return Ok("Untitled Call".to_string());+ return Ok(None);}let summary_for_prompt: &str = if trimmed_summary.len() > CALL_NAME_SUMMARY_CHAR_CAP {@@ -112,10 +140,7 @@ impl CallSummarizer for AiCallSummarizer {trimmed_summary};- let user_message = format!(- "Call {call_id} summary follows. Produce a title per the rules in \- the system prompt.\n\n{summary_for_prompt}"- );+ let user_message = format!("Summary:\n\n{summary_for_prompt}");let request = RequestBuilder::new().model(SUMMARIZATION_MODEL)@@ -138,21 +163,22 @@ impl CallSummarizer for AiCallSummarizer {mod test;/// Trim quotes/whitespace, normalize internal whitespace, and clamp to-/// [`CALL_NAME_MAX_CHARS`] at a word boundary so the persisted name is-/// well-formed regardless of model output.-fn sanitize_call_name(raw: &str) -> String {+/// [`CALL_NAME_MAX_CHARS`] at a word boundary. Returns `None` when the model+/// emitted [`UNTITLED_CALL_SENTINEL`] or sanitization left nothing usable, so+/// the caller can leave the existing call name untouched.+fn sanitize_call_name(raw: &str) -> Option<String> {let trimmed = raw.trim().trim_matches(|c: char| c == '"' || c == '\'' || c == '`').trim();let normalized = trimmed.split_whitespace().collect::<Vec<_>>().join(" ");- if normalized.is_empty() {- return "Untitled Call".to_string();+ if normalized.is_empty() || normalized.eq_ignore_ascii_case(UNTITLED_CALL_SENTINEL) {+ return None;}if normalized.chars().count() <= CALL_NAME_MAX_CHARS {- return normalized;+ return Some(normalized);}let mut taken = String::with_capacity(CALL_NAME_MAX_CHARS);@@ -163,7 +189,8 @@ fn sanitize_call_name(raw: &str) -> String {if let Some(idx) = taken.rfind(char::is_whitespace) {taken.truncate(idx);}- taken.trim_end().to_string()+ let cut = taken.trim_end().to_string();+ if cut.is_empty() { None } else { Some(cut) }}/// Render the transcript as a chronological, speaker-labeled block suitablediff --git a/rust/cloud-storage/call/src/outbound/ai_call_summarizer/test.rs b/rust/cloud-storage/call/src/outbound/ai_call_summarizer/test.rsindex 82ccaf16db..05cdaccb4b 100644--- a/rust/cloud-storage/call/src/outbound/ai_call_summarizer/test.rs+++ b/rust/cloud-storage/call/src/outbound/ai_call_summarizer/test.rs@@ -1,34 +1,47 @@-use super::{CALL_NAME_MAX_CHARS, sanitize_call_name};+use super::{CALL_NAME_MAX_CHARS, UNTITLED_CALL_SENTINEL, sanitize_call_name};#[test]fn sanitize_strips_quotes_and_whitespace() {assert_eq!(- sanitize_call_name(" \"Q4 Planning Sync\" "),- "Q4 Planning Sync"+ sanitize_call_name(" \"Q4 Planning Sync\" ").as_deref(),+ Some("Q4 Planning Sync"));- assert_eq!(sanitize_call_name("'Standup Prep'"), "Standup Prep");- assert_eq!(sanitize_call_name("`Rocket Launch`"), "Rocket Launch");+ assert_eq!(+ sanitize_call_name("'Standup Prep'").as_deref(),+ Some("Standup Prep")+ );+ assert_eq!(+ sanitize_call_name("`Rocket Launch`").as_deref(),+ Some("Rocket Launch")+ );+}++#[test]+fn sanitize_returns_none_for_empty_or_quote_only_input() {+ assert_eq!(sanitize_call_name(""), None);+ assert_eq!(sanitize_call_name(" "), None);+ assert_eq!(sanitize_call_name("\"\""), None);}#[test]-fn sanitize_falls_back_to_untitled_for_empty_or_quote_only_input() {- assert_eq!(sanitize_call_name(""), "Untitled Call");- assert_eq!(sanitize_call_name(" "), "Untitled Call");- assert_eq!(sanitize_call_name("\"\""), "Untitled Call");+fn sanitize_returns_none_for_untitled_sentinel() {+ assert_eq!(sanitize_call_name(UNTITLED_CALL_SENTINEL), None);+ assert_eq!(sanitize_call_name("untitled_call"), None);+ assert_eq!(sanitize_call_name(" \"UNTITLED_CALL\" "), None);}#[test]fn sanitize_collapses_internal_unicode_whitespace() {assert_eq!(- sanitize_call_name(" \"Weekly\nPlanning\tSync\u{00a0}Notes\" "),- "Weekly Planning Sync Notes"+ sanitize_call_name(" \"Weekly\nPlanning\tSync\u{00a0}Notes\" ").as_deref(),+ Some("Weekly Planning Sync Notes"));}#[test]fn sanitize_truncates_to_word_boundary_under_cap() {let input = "Quarterly Goals Sync ".repeat(20);- let out = sanitize_call_name(&input);+ let out = sanitize_call_name(&input).expect("non-empty input should sanitize to Some");assert!(out.chars().count() <= CALL_NAME_MAX_CHARS);assert!(!out.ends_with(' '));assert!(out.starts_with("Quarterly Goals Sync"));@@ -37,5 +50,5 @@ fn sanitize_truncates_to_word_boundary_under_cap() {#[test]fn sanitize_preserves_short_titles_verbatim() {let input = "Rocket Launch Postmortem";- assert_eq!(sanitize_call_name(input), input);+ assert_eq!(sanitize_call_name(input).as_deref(), Some(input));}