diff --git a/src/albedo/daemon/session_naming.gleam b/src/albedo/daemon/session_naming.gleam index a3495e0fc..18e5c5e9e 100644 --- a/src/albedo/daemon/session_naming.gleam +++ b/src/albedo/daemon/session_naming.gleam @@ -39,7 +39,7 @@ pub fn read(state: session_state.State(message)) -> Result(json.Json, String) { ) None, Some(_), _ -> #( "agent", - "this session is an agent named by its parent; leave its name alone", + "this session is an agent named by whoever started it; leave its name alone", ) None, None, True -> #( "model", @@ -138,7 +138,7 @@ fn refuse_owned(current: config.Configuration) -> Result(Nil, String) { ) None, Some(_) -> Error( - "this session is an agent named by its parent; leave its name alone", + "this session is an agent named by whoever started it; leave its name alone", ) None, None -> Ok(Nil) } diff --git a/test/e2e/session_name_test.py b/test/e2e/session_name_test.py index ae0490441..84130bb38 100644 --- a/test/e2e/session_name_test.py +++ b/test/e2e/session_name_test.py @@ -8,7 +8,7 @@ daemon, its storage and a kernel's `commands` object show all of that at once. import json import unittest -from harness import Albedo, Provider, latest_user, python, text +from harness import Albedo, Provider, latest_user, python, text, wait_until def tool_output(request): @@ -34,6 +34,20 @@ class SessionNameTests(unittest.TestCase): "print(await commands.rename('apple pie recipe'))\n" "print(await commands.rename('apple pie recipe'))" ) + if "start the agents" in prompt: + return python( + "models = await agents.models()\n" + "await agents.self.spawn('child task rename', name='scout', model=models[0])\n" + "await agents.start('peer task rename', 'helper', models[0])\n" + ) + if "task rename" in prompt: + return python( + "print(await commands.rename())\n" + "try:\n" + " await commands.rename('mine')\n" + "except CommandsError as error:\n" + " print('REFUSED', error)" + ) if "who named" in prompt: return python("print(await commands.rename())") if "long name" in prompt or "blank name" in prompt: @@ -139,6 +153,21 @@ class SessionNameTests(unittest.TestCase): ["name"], ) + def test_an_agent_is_named_by_whoever_started_it_not_by_the_user(self): + # Creating one fills `name` too, so only who started it tells them apart. + with Albedo(self.provider) as app: + session = app.session() + self.turn(app, session, "start the agents") + wait_until( + lambda: sum("REFUSED" in output for output in self.outputs) >= 2, + 30, + f"the child and the peer never answered: {self.outputs}", + ) + for output in (o for o in self.outputs if "REFUSED" in o): + self.assertIn("'source': 'agent'", output) + self.assertIn("whoever started it", output) + self.assertNotIn("the user named", output) + def test_a_name_must_be_a_few_words(self): with Albedo(self.provider) as app: session = app.session()