Skip to content

Commit d858cca

Browse files
committed
test(personas): expect the persona's own trait paragraph on a runtime with no learning layer
Signed-off-by: jddunn <[email protected]>
1 parent eb43e92 commit d858cca

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎src/api/__tests__/agentos-learning-tools.e2e.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* a model (the OpenAI provider class stubbed at its module boundary) that calls them, and the tool results the next
55
* model call receives. With the learning flag on, a placeholder user's turn has no learner and the tools refuse
66
* (`no_learner`); in mode `off` they refuse (`off`). With the flag off adapt_personality changes an editable trait as
7-
* before, and the trait it changes reaches no prompt; honesty and emotionality it refuses on every host
7+
* before, and the trait it changes reaches no prompt, which carries the persona's own trait paragraph as defined;
8+
* honesty and emotionality it refuses on every host
89
* (`operator_only`), since only the persona definition sets them.
910
*/
1011
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -39,6 +40,7 @@ vi.mock('../../core/llm/providers/implementations/OpenAIProvider', () => {
3940

4041
import { AgentOS } from '../AgentOS';
4142
import type { IPersonaDefinition } from '../../cognition/substrate/personas/IPersonaDefinition';
43+
import { renderPersonalitySection } from '../../cognition/substrate/personas/personalityPrompt';
4244

4345
const HEADING = '## Personality & Communication Style';
4446
const tutor = {
@@ -105,7 +107,9 @@ describe('the self-modification tools on the full runtime', () => {
105107
await send(booted, { userId: 'ana', sessionId: 's-1', textInput: 'Again.' });
106108
const [first, afterTool, nextTurn] = provider.seenMessages;
107109
expect(toolMessages(afterTool)[0]).toContain('"newValue"');
108-
expect(systemTextOf(first)).not.toContain(HEADING);
110+
// With no learning layer the GMI renders the persona's own trait paragraph once, from the definition.
111+
expect(systemTextOf(first)).toContain(renderPersonalitySection(tutor.personalityTraits)!);
112+
expect(systemTextOf(first).split(HEADING)).toHaveLength(2);
109113
expect(systemTextOf(afterTool)).toBe(systemTextOf(first));
110114
expect(systemTextOf(nextTurn)).toBe(systemTextOf(first));
111115
});

‎src/api/__tests__/agentos-learning.e2e.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file agentos-learning.e2e.test.ts
3-
* The full runtime with the learning flag off and on. Off (unset or false): no layer, and the runtime's GMIs send
4-
* no personality section, as before. On: every GMI sends its persona's section after the base prompt, in the words
3+
* The full runtime with the learning flag off and on. Off (unset or false): no layer, and each of the runtime's GMIs
4+
* renders its persona's own personality section. On: every GMI sends its persona's section after the base prompt, in the words
55
* agent() sends; each session is bound to the user and the resolved organization of its first turn; and
66
* getLearningLayer() returns the layer, built from `learning` or passed in `gmiManagerConfig`. AgentOS.create() over
77
* inline personas; only the OpenAI provider class is stubbed, at its module boundary.
@@ -79,11 +79,12 @@ afterEach(async () => {
7979
});
8080

8181
describe('the full runtime with the learning flag off', () => {
82-
it('sends no personality section with learning unset, the same system text with learning false, and has no learning layer', async () => {
82+
it("sends the persona's own personality section with learning unset, the same system text with learning false, and has no learning layer", async () => {
8383
booted = await boot();
8484
const unset = await send(booted, { userId: 'u', sessionId: 's-1', selectedPersonaId: 'tutor' });
8585
expect(unset).toContain('You teach networking.');
86-
expect(unset).not.toContain(HEADING);
86+
expect(unset).toContain(renderPersonalitySection(TRAITS)!);
87+
expect(unset.split(HEADING)).toHaveLength(2);
8788
expect(booted.getLearningLayer()).toBeUndefined();
8889
await booted.shutdown();
8990
booted = await boot({ learning: false });

‎src/api/__tests__/learning-store-and-scopes.e2e.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4972,7 +4972,9 @@ describe('the learning option and its fields, on gmi() and the full runtime', ()
49724972
try {
49734973
unsetSystem = await turn(unset);
49744974
expect(unsetSystem).toContain('You teach networking.');
4975-
expect(unsetSystem).not.toContain(PERSONALITY_HEADING);
4975+
// With no learning layer the GMI renders the persona's own trait paragraph.
4976+
expect(unsetSystem).toContain(PERSONALITY_HEADING);
4977+
expect(unset.getLearningLayer()).toBeUndefined();
49764978
} finally {
49774979
await unset.shutdown();
49784980
}

0 commit comments

Comments
 (0)