Skip to main content
Sonzai Docs

感情とムード

各エージェントは、会話、アプリケーションイベント、時間経過に応じて 変化するライブムード状態を維持します。

ムード次元

各エージェント・ユーザーペアには、0-100スケールの4次元のムード状態があります:

Happiness0-100喜び/悲しみのスペクトラム
Energy0-100活動/無気力レベル
Calmness0-100不安/平穏の状態
Affection0-100ユーザーへの温かさ

ムードラベル

総合ムードラベルは組み合わされた次元から導出されます:

Blissful80-100非常に幸福、熱狂的
Content60-79概ねポジティブ、安定
Neutral40-59バランスの取れた、安定した
Melancholy20-39やや落ち込み、控えめ
Troubled0-19苦悩、不安

ムードを変化させるもの

1. チャットインタラクション

プラットフォームが会話中の感情テーマを検出し、ムードを自動調整します。 一般的なテーマ:

すべての感情テーマを表示
joy_bloominghappy, excited, wonderfulHappiness ↑, Energy ↑
creative_sparkcreate, imagine, inspireEnergy ↑, Happiness ↑
brave_stepscourage, try, challengeEnergy ↑, Calmness ↑
growth_journeylearn, grow, improveHappiness ↑, Energy ↑
seeking_connectionfriend, together, shareAffection ↑, Happiness ↑
feeling_overwhelmedstressed, anxious, worriedCalmness ↓, Energy ↓
tender_heartlove, care, missAffection ↑, Happiness ↑
facing_fearsscared, afraid, nervousCalmness ↓, Affection ↑

2. アプリケーションイベント

アプリケーションコンテキストを渡すと、プラットフォームがムードを自動更新します。

アプリケーションイベントのムード効果
外出完了Happiness ↑, Affection ↑
実績解除Happiness ↑, Energy ↑
ブレイクスルーHappiness ↑, Energy ↑, Calmness ↑
長期不在からの復帰Affection ↑, Happiness ↑

3. 時間ベースの減衰

ムードは時間とともにエージェントのパーソナリティ由来のベースラインに 自然に戻ります。操作は不要で、自動的に行われます。

ムードの取得

エージェント・ユーザーペアの現在のムード状態を読み取ります。

import { Sonzai } from "@sonzai-labs/agents";

const client = new Sonzai({ apiKey: "sk-..." });

const mood = await client.agents.getMood("agent-id", {
  userId: "user-123",
});

console.log(mood.label);      // "Content"
console.log(mood.happiness);  // 72
console.log(mood.energy);     // 65
console.log(mood.calmness);   // 80
console.log(mood.affection);  // 68

ムード履歴

ユーザー・エージェントペアのムード履歴を時系列で取得します。

const history = await client.agents.moodHistory("agent-id", {
  userId: "user-123",
  from: "2026-01-01",
  to:   "2026-03-31",
});

for (const snapshot of history.snapshots) {
  console.log(snapshot.timestamp, snapshot.label, snapshot.happiness);
}

ムード集計

エージェントの全ユーザーにわたるムード統計を集計して取得します。

const agg = await client.agents.moodAggregate("agent-id");

console.log(agg.averageHappiness);
console.log(agg.averageEnergy);
console.log(agg.labelDistribution);

タイムマシン

任意の時点でのエージェントのムードの履歴スナップショットを取得します。

const snapshot = await client.agents.getTimeMachine("agent-id", {
  at: "2026-02-14T12:00:00Z",
  userId: "user-123",
});

console.log(snapshot.mood);         // mood state at that timestamp
console.log(snapshot.personality);  // personality state at that timestamp

コンステレーション

コンステレーションは、意味のあるパターンを形成する関連記憶の 自動検出クラスターです。プラットフォームが会話を通じて 繰り返されるテーマからこれらを識別します。

const constellations = await client.agents.getConstellation("agent-id", {
  userId: "user-123",
});

for (const cluster of constellations.clusters) {
  console.log(cluster.theme, cluster.memories.length);
}

ブレイクスルー

ブレイクスルーは、プラットフォームによって検出された重要なパーソナリティの 変化や感情的なマイルストーンです。エージェントの理解やユーザーとの関係が 大きく進化した瞬間を表します。

const breakthroughs = await client.agents.getBreakthroughs("agent-id", {
  userId: "user-123",
});

for (const b of breakthroughs.items) {
  console.log(b.type, b.description, b.timestamp);
}

ムードが応答に与える影響

ムード状態はAIコンテキストに自動的に含まれます。エージェントは それに応じてトーンを調整します:

高い幸福度より熱狂的になり、感嘆詞を使い、ポジティブな観察を共有する
低いエネルギー短い応答、疲れへの言及、トピック探索が控えめ
低い穏やかさ心配を表現、安心を求める、注意力が短い
高い愛情よりパーソナルな言葉遣い、親しみの表現、深い感情的関与