Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-18392-betty-persona.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Hive attends meetings as Betty.** The meeting bot now joins as "Betty Bee from the hive" (`meetings.persona`, on by default), introduces herself on request, answers briefly when addressed by name, and answers room questions nobody else answered within 8 seconds, from the hive's knowledge vaults, beads and code maps, under strict caps (2 unprompted answers per 10 minutes, 90 seconds apart, 12 per meeting, one reply per question). Spek's spoken replies are dropped, its chat posts go through Betty so the meeting never gets two answers, and its clarifying questions are reworded in her voice. The consent notice names Betty and says "betty leave" or "hive leave" removes her; the persona's name, aliases, language, voice, pronouns, humor and caps are configurable, and `meetings.persona.enabled: false` restores the plain `hive (notes)` attendee ([#18392](https://github.com/hivecommons/hive/issues/18392)).
2 changes: 1 addition & 1 deletion src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3591,7 +3591,7 @@ func (b *boot) bootDashboardAPIWith(deps bootDashboardAPIDeps) {
rt = b.agentMgr
}
researchPool := wireMeetingsResearch(b.cfg, rt, b.logger)
if lr := wireMeetingsLive(b.cfg, mgr, store, b.knowledgeAPI, researchPool, b.logger); lr != nil {
if lr := wireMeetingsLive(b.cfg, mgr, store, b.knowledgeAPI, func() map[string]*beads.Store { return b.beadStores }, researchPool, b.logger); lr != nil {
b.meetingsLive = lr
b.cleanup.push(lr.Close)
b.cleanup.push(routeResearch(researchPool, lr))
Expand Down
62 changes: 58 additions & 4 deletions src/cmd/hive/meetingswire.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ package main
import (
"context"
"log/slog"
"net/http"
"os"
"path/filepath"
"strconv"
"time"

"github.com/hivecommons/hive/pkg/beads"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/knowledge"
"github.com/hivecommons/hive/pkg/meetings"
"github.com/hivecommons/hive/pkg/meetings/betty"
"github.com/hivecommons/hive/pkg/meetings/live"
"github.com/hivecommons/hive/pkg/meetings/meetllm"
"github.com/hivecommons/hive/pkg/meetings/quorumproc"
Expand Down Expand Up @@ -119,6 +122,7 @@ func wireMeetingsManager(cfg *config.Config, sup quorumSupervisor, logger *slog.
Quorum: meetings.NewClient(sup.BaseURL(), sup.Token(), nil),
BotName: cfg.Meetings.BotNameOrDefault(),
ConsentText: cfg.Meetings.ConsentTextOrDefault(),
LeavePhrases: cfg.Meetings.Persona.Resolve().LeavePhrases,
LobbyTimeout: time.Duration(cfg.Meetings.LobbyTimeoutSOrDefault()) * time.Second,
Logger: logger,
// Vexa fixes speaking ability at join time, so with voice-on-address
Expand Down Expand Up @@ -153,9 +157,10 @@ func meetingSpekArgs(m meetings.Meeting, contextDir string) []string {
// manager (hivecommons/hive#18291): one `spektacular meeting` child per live
// meeting, its intents applied through the meetings policy. research may be
// nil until the research pool is wired; research intents then fail visibly
// in the panel instead of silently.
// in the panel instead of silently. beadStores feeds the persona's work-item
// retrieval and may be nil.
func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings.Store, kapi *knowledge.KnowledgeAPI,
research live.ResearchDispatcher, logger *slog.Logger) *live.Runner {
beadStores func() map[string]*beads.Store, research live.ResearchDispatcher, logger *slog.Logger) *live.Runner {
if cfg == nil || mgr == nil || store == nil {
return nil
}
Expand All @@ -175,6 +180,11 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
if kapi != nil {
notes = live.KnowledgeNotes{API: kapi}
}
persona := m.Persona.Resolve()
personaName := "Hive"
if persona.Enabled {
personaName = persona.Name
}
r, err := live.NewRunner(live.Options{
Meetings: mgr,
Store: store,
Expand All @@ -198,8 +208,11 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
MaxTokensPerMeeting: m.Budget.MaxTokensPerMeetingOrDefault(),
MaxIntentsPerMeeting: m.Budget.MaxIntentsPerMeetingOrDefault(),
},
Ledger: live.NewLedger(m.Budget.MaxTokensPerHourOrDefault(), m.Budget.MaxTokensPerDayOrDefault()),
Logger: logger,
Ledger: live.NewLedger(m.Budget.MaxTokensPerHourOrDefault(), m.Budget.MaxTokensPerDayOrDefault()),
Logger: logger,
Persona: meetingPersonaFactory(cfg, persona, llm, store, kapi, beadStores, slotsDir, maxTokens, logger),
PersonaName: personaName,
IsLeave: meetings.NewLeaveMatcher(persona.LeavePhrases).Match,
})
if err != nil {
if logger != nil {
Expand All @@ -211,6 +224,47 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
return r
}

// meetingPersonaFactory builds the meeting attendee persona (Betty,
// hivecommons/hive#18392) for each live meeting, or returns nil when the
// persona is off. She retrieves from the in-memory knowledge vaults, code
// maps (when enabled) and bead stores, and answers through the meetings
// model (`meetllm`, charged to the meeting's usage file and budget). With no
// OpenAI-compatible meetings model she still introduces herself but does
// not answer questions.
func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPersona, llm config.ResolvedMeetingsLLM,
store *meetings.Store, kapi *knowledge.KnowledgeAPI, beadStores func() map[string]*beads.Store,
slotsDir string, maxTokens int, logger *slog.Logger) func(meetings.Meeting) *betty.Engine {
if !persona.Enabled {
return nil
}
var retrievers []betty.Retriever
if kapi != nil {
stores := betty.FileStores(kapi.FileStores)
retrievers = append(retrievers, betty.KnowledgeRetriever{Stores: stores})
if cfg.Knowledge.CodeMaps.IsEnabled() {
retrievers = append(retrievers, betty.CodeMapRetriever{Stores: stores})
}
}
if beadStores != nil {
retrievers = append(retrievers, betty.BeadRetriever{Stores: beadStores})
}
client := &http.Client{}
return func(mt meetings.Meeting) *betty.Engine {
var model betty.LLM
if llm.Backend == config.MeetingsLLMModeOpenAI {
model = betty.MeetLLM{Client: client, Config: meetllm.Config{
Endpoint: llm.Endpoint, Model: llm.Model, APIKey: llm.APIKey,
// The engine bounds each call itself (2.5 s unprompted, 4 s
// addressed, 800 ms restyle); this is the outer cap.
Timeout: betty.DefaultAddressedTimeout,
UsageFile: meetingUsageFile(store, mt.ID), MaxTokens: maxTokens,
SlotsDir: slotsDir, MaxInFlight: llm.MaxInFlight,
}}
}
return betty.New(betty.SettingsFrom(persona), betty.Deps{LLM: model, Retrievers: retrievers, Logger: logger})
}
}

// meetingLLMSlotsDir holds the in-flight slot locks `hive meeting-llm`
// shares across meetings; the leading dot keeps it out of the meeting list.
const meetingLLMSlotsDir = ".llm-slots"
Expand Down
57 changes: 57 additions & 0 deletions src/cmd/hive/meetingswire_persona_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"log/slog"
"testing"

"github.com/hivecommons/hive/pkg/beads"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/knowledge"
"github.com/hivecommons/hive/pkg/meetings"
)

func TestMeetingPersonaFactory(t *testing.T) {
store, err := meetings.NewStore(t.TempDir())
if err != nil {
t.Fatal(err)
}
on := true
cfg := &config.Config{}
cfg.Knowledge.CodeMaps.Enabled = &on
persona := cfg.Meetings.Persona.Resolve()
llm := config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeOpenAI, Endpoint: "http://127.0.0.1:1", Model: "m", MaxInFlight: 1}
beadStores := func() map[string]*beads.Store { return nil }
fn := meetingPersonaFactory(cfg, persona, llm, store, &knowledge.KnowledgeAPI{}, beadStores, t.TempDir(), 100, slog.New(slog.DiscardHandler))
if fn == nil {
t.Fatal("the persona is on by default")
}
e := fn(meetings.Meeting{ID: "mtg-1"})
if e == nil || e.Name() != "Betty" {
t.Fatal("want Betty")
}
e.Close()
// Without an OpenAI-compatible model Betty still runs (intros only).
if e := meetingPersonaFactory(cfg, persona, config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeNone}, store, nil, nil, "", 0, nil)(meetings.Meeting{ID: "m2"}); e == nil {
t.Fatal("want an engine without a model")
}
off := false
cfg.Meetings.Persona.Enabled = &off
if meetingPersonaFactory(cfg, cfg.Meetings.Persona.Resolve(), llm, store, nil, nil, "", 0, nil) != nil {
t.Fatal("persona off means no factory")
}
r := wireMeetingsLive(cfg, mustManager(t, store), store, nil, nil, nil, nil)
if r == nil {
t.Fatal("live loop without the persona")
}
r.Close()
}

func mustManager(t *testing.T, store *meetings.Store) *meetings.Manager {
t.Helper()
mgr, err := meetings.NewManager(meetings.Options{Store: store, Quorum: meetings.NewClient("http://127.0.0.1:1", "t", nil)})
if err != nil {
t.Fatal(err)
}
t.Cleanup(mgr.Close)
return mgr
}
4 changes: 2 additions & 2 deletions src/cmd/hive/meetingswire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestWireMeetingsManager(t *testing.T) {
}

func TestWireMeetingsLive(t *testing.T) {
if wireMeetingsLive(nil, nil, nil, nil, nil, nil) != nil {
if wireMeetingsLive(nil, nil, nil, nil, nil, nil, nil) != nil {
t.Fatal("nil inputs must not build a live loop")
}
dir := t.TempDir()
Expand All @@ -203,7 +203,7 @@ func TestWireMeetingsLive(t *testing.T) {
}
defer mgr.Close()
cfg := &config.Config{Meetings: config.MeetingsConfig{Enabled: true}}
r := wireMeetingsLive(cfg, mgr, store, &knowledge.KnowledgeAPI{}, nil, slog.New(slog.DiscardHandler))
r := wireMeetingsLive(cfg, mgr, store, &knowledge.KnowledgeAPI{}, nil, nil, slog.New(slog.DiscardHandler))
if r == nil {
t.Fatal("want a live runner")
}
Expand Down
23 changes: 22 additions & 1 deletion src/docs/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Hive as a live meeting participant ([#18284](https://github.com/hivecommons/hive
| `HIVE_MEETINGS_TRANSCRIBE_TOKEN_FILE` | No | `/data/secrets/meetings_transcribe_token` | Keystore-sealed secret file holding the transcription service token. Overrides `meetings.transcribe_token_file`. |
| `HIVE_MEETINGS_DELIVERY` | No | `chat` | Default delivery for meeting output. Only `chat` is supported. |
| `HIVE_MEETINGS_VOICE_ON_ADDRESS` | No | `true` | Lets hive speak when addressed by name in a meeting whose voice is enabled; otherwise it answers in chat. |
| `HIVE_MEETINGS_BOT_NAME` | No | `hive (notes)` | Display name the meeting bot joins with. |
| `HIVE_MEETINGS_BOT_NAME` | No | the persona's display name (`Betty Bee from the hive`), or `hive (notes)` with the persona off | Display name the meeting bot joins with. |
| `HIVE_MEETINGS_INVITE_POLICY` | No | `owner` | Who may send hive to a meeting. Only `owner` is supported. |
| `HIVE_MEETINGS_RESEARCH_POOL_SIZE` | No | `2` | Number of research agents (`research-1..N`). |
| `HIVE_MEETINGS_RESEARCH_PER_MEETING` | No | `5` | Research items one meeting may start before each further item needs dashboard approval. |
Expand All @@ -400,6 +400,27 @@ Hive as a live meeting participant ([#18284](https://github.com/hivecommons/hive
| `HIVE_MEETINGS_MAX_TOKENS_PER_HOUR` | No | `500000` | Hive-wide hourly token ceiling across meetings. |
| `HIVE_MEETINGS_MAX_TOKENS_PER_DAY` | No | `2000000` | Hive-wide daily token ceiling across meetings. |
| `HIVE_MEETINGS_MAX_INTENTS_PER_MEETING` | No | `500` | Per-meeting budget counted in Spek intents when Spek reports no token usage. |
| `HIVE_MEETINGS_PERSONA_ENABLED` | No | `true` | Turns the meeting attendee persona (Betty) on or off. Off restores the plain `hive (notes)` attendee. |
| `HIVE_MEETINGS_PERSONA_PRESET` | No | `betty` | Built-in persona the fields below start from. |
| `HIVE_MEETINGS_PERSONA_NAME` | No | `Betty` | Name the persona answers to and uses for itself. |
| `HIVE_MEETINGS_PERSONA_DISPLAY_NAME` | No | `Betty Bee from the hive` | Meeting display name; the default bot name. At most 64 characters. |
| `HIVE_MEETINGS_PERSONA_ALIASES` | No | `betty,betty bee,hive` | Comma-separated names that address the persona at the start or end of a line. |
| `HIVE_MEETINGS_PERSONA_PRONOUNS` | No | `she/her` | Pronouns used in the intro and self-description only. |
| `HIVE_MEETINGS_PERSONA_LANGUAGE` | No | `en-US` | BCP-47 tag; replies use its language and regional conventions. |
| `HIVE_MEETINGS_PERSONA_VOICE` | No | `af_heart` | TTS voice id for spoken replies (Kokoro; stored for spoken replies, not used yet). |
| `HIVE_MEETINGS_PERSONA_VOICE_TYPE` | No | `female` | `female`, `male` or `bot`; descriptive only. |
| `HIVE_MEETINGS_PERSONA_ACCENT` | No | `American` | Free text; descriptive only. |
| `HIVE_MEETINGS_PERSONA_INTRO_TEMPLATE` | No | the preset's intro | Intro posted when someone asks the persona to introduce itself. Placeholders `{name}`, `{display_name}`, `{pronouns}`, `{leave}`, `{accent}`, `{voice_type}`, `{language}`. |
| `HIVE_MEETINGS_PERSONA_LEAVE_PHRASES` | No | `betty leave,hive leave` | Comma-separated phrases that remove the persona from the meeting. |
| `HIVE_MEETINGS_PERSONA_HUMOR` | No | `light` | `light` (at most one light touch, never about a person) or `off`. |
| `HIVE_MEETINGS_PERSONA_SEARXNG_URL` | No | none | Web search service for the persona (not used yet). |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_PER_10M` | No | `2` | Unprompted (question-driven) answers per ten minutes. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_MIN_GAP_S` | No | `90` | Minimum seconds between two unprompted answers. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_PER_MEETING` | No | `12` | Unprompted answers per meeting. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_ANSWER_WAIT_S` | No | `8` | Seconds the persona waits for a person to answer a room question first. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_MIN_CONFIDENCE` | No | `0.75` | Model confidence (0 to 1) an unprompted answer needs. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_QUEUE_DEPTH` | No | `3` | Room questions waiting for an answer at once. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_STALE_S` | No | `60` | Seconds after which a waiting room question is dropped. |
| `HIVE_MEETINGS_LLM_MODE` | No | `auto` | Model Spektacular live mode reasons with: `auto` (an Anthropic key if set, else the OpenAI-compatible endpoint), `openai`, `anthropic` or `none` (rules only). |
| `HIVE_MEETINGS_LLM_ENDPOINT` | No | `governor.litellm` endpoint | OpenAI-compatible base URL `hive meeting-llm` calls for Spek. |
| `HIVE_MEETINGS_LLM_MODEL` | No | `governor.litellm.default_model` | Model name for that endpoint. Without an endpoint and model, Spek runs on rules only. |
Expand Down
Loading
Loading