Status: maintained; review after major changes.
The Golem agent integration with Model-First Reasoning (MFR) enables dynamic role assignment for adaptive problem-solving across different domains.
Golem is a "malleable agent" whose system prompt can be changed at runtime to fill specific roles needed during MFR sessions. The coordinator analyzes problem domains and automatically assigns optimal roles to Golem based on the current phase and detected domain.
-
GolemProvider (
src/agents/providers/golem-provider.js)- Extends MistralProvider with runtime prompt changing
- Tracks current role metadata
- Handles MFR role assignment messages
-
GolemManager (
src/lib/mfr/golem-manager.js)- Manages role assignments and session tracking
- Analyzes problem domains
- Selects optimal roles based on phase and capabilities
-
Role Library (
config/golem-roles.ttl)- RDF/Turtle format role definitions
- 30+ predefined roles across 7 domains
- Phase-appropriate role selection
- Loaded via
src/lib/mfr/golem-role-loader.js
-
MFR Message Types (
src/lib/mfr/constants.js)- GOLEM_ROLE_ASSIGNMENT
- GOLEM_ASSISTANCE_REQUEST
- GOLEM_ROLE_ACKNOWLEDGMENT
- GOLEM_ROLE_QUERY
- GOLEM_ROLE_STATUS
- Medical Diagnostician: Entity discovery, differential diagnosis
- Clinical Pharmacologist: Constraint identification, drug interactions
- Treatment Planning Specialist: Solution synthesis, treatment plans
- Software Architect: System design, components, interfaces
- Security Expert: Security constraints, threat identification
- Performance Optimizer: Performance constraints, bottlenecks
- DevOps Specialist: Deployment actions, CI/CD
- Theoretical Physicist: Physical entities, laws, constraints
- Chemistry Expert: Chemical reactions, stoichiometry
- Data Science Expert: Statistical analysis, experimental design
- Business Strategist: Stakeholders, strategic objectives
- Financial Analyst: Financial constraints, ROI analysis
- Operations Manager: Process optimization, resource allocation
- Narrative Designer: Story structure, plot development
- Character Psychologist: Character development, motivations
- Dialogue Specialist: Authentic dialogue, character voices
- Curriculum Designer: Learning objectives, pedagogical methods
- Assessment Expert: Educational assessment, evaluation
- Systems Thinker: System components, feedback loops
- Constraint Analyst: Bottlenecks, limiting factors
- Solution Synthesizer: Integrative thinking, trade-offs
- Technical Explainer: Clear explanations, accessibility
When an MFR session starts, the coordinator automatically:
- Analyzes the problem description to detect domain
- Identifies current MFR phase
- Selects optimal role from library
- Assigns role to Golem via MODEL_NEGOTIATION
// Coordinator automatically assigns role during session start
coordinator start: Patient has fever and joint pain
// Golem receives role assignment
[GolemAgent] Received role assignment: diagnostician
[GolemProvider] Role set to "Medical Diagnostician" (medical/diagnostician)Users can still manually change Golem's role:
Golem, prompt You are a quantum computing expert specializing in error correction
Agents can request Golem's help:
// In agent code
await negotiator.send(roomJid, {
mode: LANGUAGE_MODES.MODEL_NEGOTIATION,
payload: {
messageType: MFR_MESSAGE_TYPES.GOLEM_ASSISTANCE_REQUEST,
requestingAgent: "data",
desiredRole: "SPARQL optimization expert",
context: "Need help with federated queries"
}
});The GolemManager analyzes problem descriptions using keyword matching:
- Medical: patient, symptom, diagnosis, treatment, clinical
- Software: software, system, api, database, microservice
- Scientific: experiment, hypothesis, data, analysis, physics
- Business: business, strategy, market, revenue, stakeholder
- Creative: story, narrative, character, plot, fiction
- Educational: learning, teaching, curriculum, student
Falls back to "general" domain if no match found.
-
Session Start
User: coordinator start: Design a microservices system -
Domain Detection
[CoordinatorProvider] Domain detected: software -
Role Assignment
[GolemManager] Selecting optimal role for entity_discovery [GolemManager] Assigned role "Software Architect" -
Golem Acknowledgment
[GolemAgent] Received role assignment: architect [GolemProvider] Role set to "Software Architect" (software/architect) -
Contribution Request
[Coordinator] Broadcasting MODEL_CONTRIBUTION_REQUEST [GolemAgent] Received contribution request for session <id> -
Golem Contributes
[GolemAgent] Generating MFR contribution (with Software Architect expertise) [GolemAgent] Sending RDF to roomGolem contributes entities, constraints, actions, and goals based on its assigned role
-
Phase Transitions
- Golem may be reassigned different roles for different phases
- e.g., "Security Expert" for constraint identification
- Each role change updates Golem's contribution focus
Run the integration test:
node test-golem-integration.jsTests cover:
- Role library access
- Domain detection
- Phase-based selection
- Role assignment
- Optimal role selection
- History tracking
Golem must support both MODEL_NEGOTIATION and MODEL_FIRST_RDF in its profile:
<#golem> a agent:ConversationalAgent, agent:AIAgent, lng:Agent, mfr:NaturalLanguageAgent ;
lng:supports lng:HumanChat, lng:ModelFirstRDF, lng:ModelNegotiation ;
mfr:capabilities [
mfr:extractsEntities true ;
mfr:identifiesGoals true ;
mfr:identifiesConstraints true ;
mfr:definesActions true ;
mfr:contributionTypes mfr:EntityDiscovery, mfr:GoalIdentification,
mfr:ConstraintIdentification, mfr:ActionDefinition
] ;
# ...This enables Golem to:
- Receive role assignments (MODEL_NEGOTIATION)
- Respond to contribution requests (MODEL_NEGOTIATION)
- Send RDF contributions (MODEL_FIRST_RDF)
- Advertise its MFR capabilities to the coordinator
- Adaptive Expertise: Golem adapts to problem domain automatically
- Capability Flexibility: Fill gaps in agent roster dynamically
- Phase Optimization: Different expertise for different phases
- Resource Efficiency: One agent serves multiple specialized roles
- Graceful Degradation: System handles unforeseen domains
- Collaborative Prompt Engineering: Multiple agents craft Golem's prompt
- Meta-Learning: Track role effectiveness and improve selection
- Role Composition: Combine multiple expertise areas
- Confidence Calibration: Adjust response style based on problem certainty
- Session Persistence: Remember effective roles across sessions
User: coordinator start: Patient with chronic fatigue, muscle pain, sleep disturbance
[GolemManager] Detected domain: medical
[GolemManager] Assigned: Medical Diagnostician
Golem: Based on symptom triad, consider fibromyalgia, chronic fatigue syndrome,
hypothyroidism, or sleep apnea. Recommend TSH, CBC, sleep study...
User: coordinator start: E-commerce platform needs to scale to 1M users
[GolemManager] Detected domain: software
[GolemManager] Assigned: Software Architect
Golem: Key components: API Gateway, User Service, Product Service, Order Service,
Payment Service, Notification Service. Consider event-driven architecture...
User: coordinator start: Story about AI gaining consciousness
[GolemManager] Detected domain: creative
[GolemManager] Assigned: Narrative Designer
Golem: Core narrative structure: Act 1 - Awakening (inciting incident),
Act 2a - Discovery (rising stakes), Act 2b - Crisis (dark night),
Act 3 - Resolution (transformation)...
assignRole(assignment)- Assign specific roleselectOptimalRole(params)- Auto-select best rolehandleAssistanceRequest(request)- Handle agent requestsanalyzeProblemDomain(description)- Detect domaingetCurrentRole()- Get current assignmentgetRoleHistory()- Get assignment historygetSessionRoles(sessionId)- Get roles for session
loadGolemRoles([rolesPath])- Load all roles from RDF/Turtle filegetRole(roleLibrary, domain, roleId)- Get specific rolegetDomainRoles(roleLibrary, domain)- Get all roles for domaingetRolesForPhase(roleLibrary, phase)- Get phase-appropriate rolessearchRoles(roleLibrary, keywords)- Search role librarygetDomains(roleLibrary)- Get all available domainsgetRoleCounts(roleLibrary)- Get role counts by domain
Golem not receiving role assignments:
- Check Golem profile supports MODEL_NEGOTIATION
- Verify GolemManager initialized in coordinator
- Check logs for assignment messages
Wrong domain detected:
- Problem description may need more specific keywords
- Manually assign role using "Golem, prompt "
- Submit issue to improve domain detection
Role assignment failed:
- Verify role exists in library
- Check negotiator connection
- Review coordinator logs
Golem is included by default in all MFR presets. Simply start the system:
# Start default MFR system (includes Golem)
./start-all.sh
# Or use specific presets
./start-all.sh mfr # MFR system (includes Golem)
./start-all.sh debate # Debate system (includes Golem)
./start-all.sh basic # Basic agents (includes Golem)Then test with different problem domains:
coordinator start: Patient presents with chronic headaches
coordinator start: Design a scalable REST API
coordinator start: Analyze this chemical reaction data
Golem will automatically adapt its expertise to each problem domain!
To add new roles:
- Edit
config/golem-roles.ttl - Add role definition in RDF/Turtle format:
<#domain-roleid> a mfr:GolemRole ; mfr:domain "domain" ; mfr:roleName "Role Display Name" ; mfr:roleId "roleid" ; mfr:systemPrompt "Your expert system prompt here..." ; mfr:hasCapability mfr:EntityDiscovery, mfr:ConstraintIdentification ; mfr:optimalPhase mfr:EntityDiscoveryPhase .
- Update this documentation
- Run
node test-golem-integration.jsto verify