-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: implement Agent Identity & Self-Awareness System #10914
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
base: main
Are you sure you want to change the base?
Conversation
Adds a comprehensive personality and identity system to maintain
consistent agent self-awareness across all interactions.
Key features:
- Personality enum (Friendly, Pragmatic) with extensibility
- InstructionsTemplate with {{ personality_message }} placeholder
- Mid-session personality change via PersonalityUpdateMessage injection
- Explicit identity disambiguation in all DEFAULT_MODES roleDefinitions
New files:
- packages/types/src/personality.ts - types and Zod schemas
- src/core/prompts/personality/ - template rendering and loading
- src/core/prompts/identity/ - disambiguation utilities
- src/core/prompts/personalities/*.md - personality content
Modified:
- Task.ts - personality state tracking and change handling
- webviewMessageHandler.ts - changePersonality message handler
- modes.ts - getModeSelection accepts personality parameter
- system.ts - passes personality through prompt generation
- mode.ts - DEFAULT_MODES include disambiguation statements
Includes 57 new unit tests.
Review status: changes look coherent overall, but there are a couple integration gaps to resolve before approval.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| * This personality will be applied across all modes unless a mode | ||
| * has its own defaultPersonality set. | ||
| */ | ||
| agentPersonality: personalitySchema.optional(), |
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.
agentPersonality is documented as a functional preference (and mentions defaultPersonality precedence), but I could not find any runtime code that reads this setting and threads it into getModeSelection()/SYSTEM_PROMPT(). As-is, this looks like a schema-only addition where the UI/state can store a value but it never affects prompts or mid-session behavior.
Fix it with Roo Code or mention @roomote and request a fix.
| public async handlePersonalityChange(newPersonality: Personality): Promise<PersonalityUpdateMessage> { | ||
| const provider = this.providerRef.deref() | ||
| if (!provider) { | ||
| throw new Error("Provider reference lost during personality change") | ||
| } | ||
|
|
||
| // Update personality tracking state | ||
| this.previousPersonality = this.currentPersonality | ||
| this.currentPersonality = newPersonality | ||
|
|
||
| // Load personality messages from markdown files | ||
| const personalityMessages = loadPersonalityContent() | ||
| if (!personalityMessages) { | ||
| throw new Error("Failed to load personality messages from markdown files") | ||
| } | ||
|
|
||
| // Build the personality update message | ||
| // If we have a previous personality, use the transition message for smoother switching | ||
| let updateMessage: PersonalityUpdateMessage | ||
| if (this.previousPersonality) { | ||
| updateMessage = buildPersonalityTransitionMessage( | ||
| this.previousPersonality, | ||
| newPersonality, | ||
| personalityMessages, | ||
| ) | ||
| } else { | ||
| // First time setting personality - use the simpler update message | ||
| const { buildPersonalityUpdateMessage } = await import("../prompts/personality/update-message") | ||
| updateMessage = buildPersonalityUpdateMessage(newPersonality, personalityMessages) | ||
| } | ||
|
|
||
| // Inject the personality update message into the conversation | ||
| // We add it as a user message containing the system-level personality directive | ||
| // This allows the model to see and adopt the new communication style | ||
| await this.addToApiConversationHistory({ | ||
| role: "user", | ||
| content: [ | ||
| { | ||
| type: "text", | ||
| text: updateMessage.content, | ||
| }, | ||
| ], | ||
| }) | ||
|
|
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.
handlePersonalityChange() builds a PersonalityUpdateMessage with a declared role (system/developer), but then injects only the content into the conversation as a role: "user" message, effectively dropping the role signal. If providers rely on role semantics (or later tooling assumes the update is system-level), this can make personality changes unreliable or misleading.
Fix it with Roo Code or mention @roomote and request a fix.
Summary
Implements a comprehensive Agent Identity & Self-Awareness System that enables Roo to maintain a consistent sense of self throughout interactions while supporting personality customization.
Changes
New Types (packages/types/src/personality.ts)
Personalityenum withFriendlyandPragmaticvaluesPersonalityMessagestype for personality-specific content mappingInstructionsTemplateinterface with{{ personality_message }}placeholder supportPersonalityUpdateMessageinterface for mid-session personality changesPersonality Content (src/core/prompts/personalities/)
friendly.md- Warm, supportive, team-oriented communication stylepragmatic.md- Direct, efficient, results-focused communication styleTemplate Rendering (src/core/prompts/personality/)
template-renderer.ts-hasPersonalityPlaceholder(),renderPersonalityTemplate(),getAgentInstructions()load-personalities.ts- Loads personality content from markdown filesupdate-message.ts-buildPersonalityUpdateMessage(),buildPersonalityTransitionMessage()Identity Disambiguation (src/core/prompts/identity/)
disambiguation.ts-IDENTITY_DISAMBIGUATIONconstant and helper functionIntegration
Task.ts- AddedcurrentPersonality,previousPersonality, andhandlePersonalityChange()methodwebviewMessageHandler.ts- AddedchangePersonalitymessage handlermodes.ts-getModeSelection()now accepts optional personality parametersystem.ts- Passes personality through prompt generation chainglobal-settings.ts- AddedagentPersonalitysettingmode.ts- AddeddefaultPersonalityandinstructionsTemplatefields to ModeConfigTesting
Architecture
Important
Implements Agent Identity & Self-Awareness System with personality customization and identity disambiguation, adding new types, models, and extensive testing.
changePersonalityhandler inwebviewMessageHandler.tsfor mid-session personality changes.Personalityenum,PersonalityMessages,InstructionsTemplate, andPersonalityUpdateMessageinpersonality.ts.template-renderer.tsprovideshasPersonalityPlaceholder(),renderPersonalityTemplate(), andgetAgentInstructions().load-personalities.tsloads personality content from markdown files.disambiguation.tsintroducesIDENTITY_DISAMBIGUATIONconstant for clear identity context.Task.tswithcurrentPersonality,previousPersonality, andhandlePersonalityChange().modes.tsto support personality ingetModeSelection().This description was created by
for c01e1bd. You can customize this summary. It will automatically update as commits are pushed.