Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jan 23, 2026

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)

  • Personality enum with Friendly and Pragmatic values
  • PersonalityMessages type for personality-specific content mapping
  • InstructionsTemplate interface with {{ personality_message }} placeholder support
  • PersonalityUpdateMessage interface for mid-session personality changes
  • Zod schemas for runtime validation

Personality Content (src/core/prompts/personalities/)

  • friendly.md - Warm, supportive, team-oriented communication style
  • pragmatic.md - Direct, efficient, results-focused communication style

Template Rendering (src/core/prompts/personality/)

  • template-renderer.ts - hasPersonalityPlaceholder(), renderPersonalityTemplate(), getAgentInstructions()
  • load-personalities.ts - Loads personality content from markdown files
  • update-message.ts - buildPersonalityUpdateMessage(), buildPersonalityTransitionMessage()
  • 57 new unit tests

Identity Disambiguation (src/core/prompts/identity/)

  • disambiguation.ts - IDENTITY_DISAMBIGUATION constant and helper function
  • All 5 DEFAULT_MODES now include explicit disambiguation: "Within this context, Roo refers specifically to this AI coding assistant integrated with VS Code (not any other system or product with a similar name)."

Integration

  • Task.ts - Added currentPersonality, previousPersonality, and handlePersonalityChange() method
  • webviewMessageHandler.ts - Added changePersonality message handler
  • modes.ts - getModeSelection() now accepts optional personality parameter
  • system.ts - Passes personality through prompt generation chain
  • global-settings.ts - Added agentPersonality setting
  • mode.ts - Added defaultPersonality and instructionsTemplate fields to ModeConfig

Testing

  • ✅ All 5153 tests pass
  • ✅ 57 new tests added for personality system
  • ✅ Type-safe with Zod schemas

Architecture

┌──────────────────────────────────────────────────────────────────┐
│                    Agent Identity System                          │
├──────────────────────────────────────────────────────────────────┤
│  roleDefinition + disambiguation  →  InstructionsTemplate        │
│                                        {{ personality }}          │
│                                              ↓                    │
│  PersonalityMessages ──────────→  TemplateRenderer               │
│  (friendly/pragmatic)                       ↓                    │
│                                   Final System Instructions       │
│                                                                   │
│  Mid-session: PersonalityUpdateMessage injection                  │
└──────────────────────────────────────────────────────────────────┘

Important

Implements Agent Identity & Self-Awareness System with personality customization and identity disambiguation, adding new types, models, and extensive testing.

  • Behavior:
    • Implements Agent Identity & Self-Awareness System for consistent self-representation and personality customization.
    • Adds changePersonality handler in webviewMessageHandler.ts for mid-session personality changes.
  • Types and Models:
    • Adds Personality enum, PersonalityMessages, InstructionsTemplate, and PersonalityUpdateMessage in personality.ts.
    • Introduces Zod schemas for validation.
  • Template Rendering:
    • template-renderer.ts provides hasPersonalityPlaceholder(), renderPersonalityTemplate(), and getAgentInstructions().
    • load-personalities.ts loads personality content from markdown files.
  • Identity Disambiguation:
    • disambiguation.ts introduces IDENTITY_DISAMBIGUATION constant for clear identity context.
  • Integration:
    • Updates Task.ts with currentPersonality, previousPersonality, and handlePersonalityChange().
    • Modifies modes.ts to support personality in getModeSelection().
  • Testing:
    • Adds 57 new unit tests for personality system.
    • All 5153 tests pass.

This description was created by Ellipsis for c01e1bd. You can customize this summary. It will automatically update as commits are pushed.

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.
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Jan 23, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 23, 2026

Oroocle Clock   See task on Roo Cloud

Review status: changes look coherent overall, but there are a couple integration gaps to resolve before approval.

  • Wire agentPersonality (and defaultPersonality) into prompt generation so the setting actually affects instructions.
  • Fix handlePersonalityChange() to preserve the intended system/developer role semantics when injecting the update message.

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(),
Copy link
Contributor

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.

Comment on lines +1601 to +1644
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,
},
],
})

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants