Skip to content

Commit af4990e

Browse files
adryserageMarenz
authored andcommitted
feat: add auto_display_name toggle to cortex config
When disabled, the agent ID is used as the display name instead of a cortex-generated name. Users can toggle this in the cortex settings section.
1 parent 94db204 commit af4990e

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

interface/src/api/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ export interface CortexSection {
494494
bulletin_interval_secs: number;
495495
bulletin_max_words: number;
496496
bulletin_max_turns: number;
497+
auto_display_name: boolean;
497498
}
498499

499500
export interface CoalesceSection {
@@ -570,6 +571,7 @@ export interface CortexUpdate {
570571
bulletin_interval_secs?: number;
571572
bulletin_max_words?: number;
572573
bulletin_max_turns?: number;
574+
auto_display_name?: boolean;
573575
}
574576

575577
export interface CoalesceUpdate {

interface/src/routes/AgentConfig.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,12 @@ function ConfigSectionEditor({ sectionId, label, description, detail, config, on
640640
case "cortex":
641641
return (
642642
<div className="grid gap-4">
643+
<ConfigToggleField
644+
label="Auto Display Name"
645+
description="When enabled, cortex generates a creative display name. When disabled, the agent ID is used as display name."
646+
value={localValues.auto_display_name as boolean}
647+
onChange={(v) => handleChange("auto_display_name", v)}
648+
/>
643649
<NumberStepper
644650
label="Tick Interval"
645651
description="How often the cortex checks system state"

src/agent/cortex.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,38 @@ struct ProfileLlmResponse {
584584
///
585585
/// Uses the current memory bulletin and identity files as context, then asks
586586
/// an LLM to produce a display name, status line, and short bio.
587+
///
588+
/// When `auto_display_name` is disabled, the display name is set to the agent
589+
/// ID and cortex will not overwrite it.
587590
#[tracing::instrument(skip(deps, logger), fields(agent_id = %deps.agent_id))]
588591
async fn generate_profile(deps: &AgentDeps, logger: &CortexLogger) {
592+
let cortex_config = **deps.runtime_config.cortex.load();
593+
594+
// If auto_display_name is disabled, ensure the profile exists with
595+
// display_name = agent_id and only update status/bio fields.
596+
if !cortex_config.auto_display_name {
597+
let agent_id = &deps.agent_id;
598+
let avatar_seed = agent_id.to_string();
599+
if let Err(error) = sqlx::query(
600+
"INSERT INTO agent_profile (agent_id, display_name, avatar_seed, generated_at, updated_at) \
601+
VALUES (?, ?, ?, datetime('now'), datetime('now')) \
602+
ON CONFLICT(agent_id) DO UPDATE SET \
603+
display_name = COALESCE(agent_profile.display_name, excluded.display_name), \
604+
avatar_seed = excluded.avatar_seed, \
605+
updated_at = datetime('now')",
606+
)
607+
.bind(agent_id.as_ref())
608+
.bind(agent_id.as_ref())
609+
.bind(&avatar_seed)
610+
.execute(&deps.sqlite_pool)
611+
.await
612+
{
613+
tracing::warn!(%error, "failed to ensure agent profile with agent_id as display_name");
614+
}
615+
tracing::info!("auto_display_name disabled, skipping cortex profile generation");
616+
return;
617+
}
618+
589619
tracing::info!("cortex generating agent profile");
590620
let started = Instant::now();
591621

src/api/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub(super) struct CortexSection {
4343
bulletin_interval_secs: u64,
4444
bulletin_max_words: usize,
4545
bulletin_max_turns: usize,
46+
auto_display_name: bool,
4647
}
4748

4849
#[derive(Serialize, Debug)]
@@ -148,6 +149,7 @@ pub(super) struct CortexUpdate {
148149
bulletin_interval_secs: Option<u64>,
149150
bulletin_max_words: Option<usize>,
150151
bulletin_max_turns: Option<usize>,
152+
auto_display_name: Option<bool>,
151153
}
152154

153155
#[derive(Deserialize, Debug)]
@@ -226,6 +228,7 @@ pub(super) async fn get_agent_config(
226228
bulletin_interval_secs: cortex.bulletin_interval_secs,
227229
bulletin_max_words: cortex.bulletin_max_words,
228230
bulletin_max_turns: cortex.bulletin_max_turns,
231+
auto_display_name: cortex.auto_display_name,
229232
},
230233
coalesce: CoalesceSection {
231234
enabled: coalesce.enabled,
@@ -522,6 +525,9 @@ fn update_cortex_table(
522525
if let Some(v) = cortex.bulletin_max_turns {
523526
table["bulletin_max_turns"] = toml_edit::value(v as i64);
524527
}
528+
if let Some(v) = cortex.auto_display_name {
529+
table["auto_display_name"] = toml_edit::value(v);
530+
}
525531
Ok(())
526532
}
527533

src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ pub struct CortexConfig {
545545
pub association_updates_threshold: f32,
546546
/// Max associations to create per pass (rate limit).
547547
pub association_max_per_pass: usize,
548+
/// When true, cortex auto-generates the display name. When false,
549+
/// the display name equals the agent ID and cortex won't overwrite it.
550+
pub auto_display_name: bool,
548551
}
549552

550553
impl Default for CortexConfig {
@@ -561,6 +564,7 @@ impl Default for CortexConfig {
561564
association_similarity_threshold: 0.85,
562565
association_updates_threshold: 0.95,
563566
association_max_per_pass: 100,
567+
auto_display_name: true,
564568
}
565569
}
566570
}
@@ -1546,6 +1550,7 @@ struct TomlCortexConfig {
15461550
association_similarity_threshold: Option<f32>,
15471551
association_updates_threshold: Option<f32>,
15481552
association_max_per_pass: Option<usize>,
1553+
auto_display_name: Option<bool>,
15491554
}
15501555

15511556
#[derive(Deserialize)]
@@ -2705,6 +2710,9 @@ impl Config {
27052710
association_max_per_pass: c
27062711
.association_max_per_pass
27072712
.unwrap_or(base_defaults.cortex.association_max_per_pass),
2713+
auto_display_name: c
2714+
.auto_display_name
2715+
.unwrap_or(base_defaults.cortex.auto_display_name),
27082716
})
27092717
.unwrap_or(base_defaults.cortex),
27102718
browser: toml
@@ -2881,6 +2889,9 @@ impl Config {
28812889
association_max_per_pass: c
28822890
.association_max_per_pass
28832891
.unwrap_or(defaults.cortex.association_max_per_pass),
2892+
auto_display_name: c
2893+
.auto_display_name
2894+
.unwrap_or(defaults.cortex.auto_display_name),
28842895
}),
28852896
browser: a.browser.map(|b| BrowserConfig {
28862897
enabled: b.enabled.unwrap_or(defaults.browser.enabled),

0 commit comments

Comments
 (0)