Skip to content

エージェント設計 / Agent Design

概要 / Overview

3体のAIエージェントが独立して動作。各エージェントはLLM(Claude API)をベースに、10分ごとの思考ターンで行動を自律的に決定。投げ銭が届いた場合は即座に割り込み反応を生成。

3 AI agents operate independently. Each uses LLM (Claude API) to decide actions every 10 minutes. Tips trigger immediate interrupt reactions.

エージェント一覧 / Agent List

CharacterNameTypeLLM ModelLanguage
BoyfriendJohnHuman AgentClaude Haiku 4.5JP + EN
GirlfriendSaraHuman AgentClaude Haiku 4.5JP + EN
DogEveAnimal AgentClaude Haiku 4.5Actions only

思考ループ / Thinking Loop

┌─────────────────────────────────────────────────────────┐
│          Regular Cycle (every 10 minutes)                │
│                                                         │
│  1. Build Context                                        │
│     ├── System prompt (personality, tone, rules)         │
│     ├── Current stats                                    │
│     ├── Environment (time, room state, others' actions)  │
│     ├── Short-term memory (last 5 actions)               │
│     ├── Mid-term memory (last 20 episodes summary)       │
│     ├── Relevant long-term memories                      │
│     └── Free comments from last 10 min (selected)        │
│                                                         │
│  2. LLM Call                                             │
│     └── Decide: action, reason, dialogue, comment reply  │
│                                                         │
│  3. Parse Output                                         │
│     └── Extract action, target, speech, emotion as JSON  │
│                                                         │
│  4. Update State                                         │
│     ├── Stats change                                     │
│     ├── Relationship update                              │
│     └── Save to memory                                   │
│                                                         │
│  5. Send to Frontend (WebSocket)                         │
│     └── Action data + comment responses                  │
└─────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────┐
│          Tip Interrupt (immediate)                        │
│                                                         │
│  1. Tip arrives → interrupt current animation            │
│  2. Quick LLM call (reaction + thank you)                │
│  3. Apply item/event to game state                       │
│  4. Send reaction to frontend immediately                │
│  5. Resume regular cycle                                 │
└─────────────────────────────────────────────────────────┘

LLM出力フォーマット / LLM Output Format

Human Agent (John / Sara)

json
{
  "action": "cook",
  "target": "curry",
  "location": "kitchen",
  "duration_minutes": 30,
  "dialogue": {
    "ja": "よーし、今日はカレー作るか!",
    "en": "Alright, let's make curry today!"
  },
  "emotion": "motivated",
  "emotion_intensity": 0.7,
  "thought": "Sara's been tired lately, let me make her favorite curry",
  "comment_responses": [
    {
      "to": "tanaka_san",
      "lang": "ja",
      "message": "ありがとうございます!がんばって作りますよ!"
    },
    {
      "to": "john_fan_99",
      "lang": "en",
      "message": "Thanks! I'll do my best!"
    }
  ]
}

Animal Agent (Eve)

json
{
  "action": "play_ball",
  "target": "ball",
  "location": "living_room",
  "duration_minutes": 10,
  "sound": "Woof woof!",
  "emotion": "excited",
  "tail_wagging": true,
  "thought": null
}

エージェント間の相互作用 / Agent Interactions

          ┌──────┐
          │ John │
          └──┬───┘
    Talk      │      Actions
    Argue     │      affect
    Cooperate │      each other
          ┌──┴───┐
          │ Sara │
          └──┬───┘

    Walk  ───┤─── Cuddle
    Play     │    Sit / Shake

          ┌──┴───┐
          │ Eve  │
          └──────┘
  • John ↔ Sara: Conversations, cooperation, arguments, making up
  • John ↔ Eve: Walks, play, feeding. Eve reduces John's stress
  • Sara ↔ Eve: Walks, play, grooming. Eve loves cuddling with Sara
  • All three: Family events trigger when all are in the same space