open-agents-ai 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -333,6 +333,12 @@ Memory flows bidirectionally: the swarm reads all 5 keys at startup (Phase 0) an
333
333
 
334
334
  The Monitor agent can be "detached" between experiment rounds by the Flow Maintainer. When detached, the monitor receives a sub-task (e.g., "analyze GPU memory patterns from last 3 runs") instead of its standard watch prompt. This lets the swarm use idle monitoring capacity for useful analysis work.
335
335
 
336
+ #### Dependency Management
337
+
338
+ The autoresearch tool uses [`uv`](https://docs.astral.sh/uv/) for zero-setup Python environment management. Running `autoresearch(action="setup")` creates a `pyproject.toml` with all dependencies (torch, kernels, pyarrow, rustbpe, tiktoken, etc.) and runs `uv sync` to create a `.venv` automatically.
339
+
340
+ If the Python scripts are invoked directly (without `uv run`), they self-bootstrap: detect missing packages, create a local `.venv`, install dependencies (including CUDA 12.8 torch), and re-exec with the venv's Python. This handles cases where the agent calls `python3 prepare.py` instead of `uv run prepare.py`.
341
+
336
342
  If no GPU is detected, the REM stage falls back to the standard multi-agent creative exploration (Visionary + Pragmatist + Cross-Pollinator + Synthesizer).
337
343
 
338
344
  ## Blessed Mode — Infinite Warm Loop
@@ -386,6 +392,23 @@ Connect the agent to a Telegram bot. Each incoming message spawns a dedicated su
386
392
 
387
393
  The bot token and admin ID are persisted to project settings, so you only need to set them once. After that, bare `/telegram` toggles the bridge on and off like a service watchdog.
388
394
 
395
+ ### Admin Slash Command Passthrough
396
+
397
+ When the admin sends a `/command` in a private DM, it's routed directly through the terminal's command handler — the same code path as typing the command in the TUI. This means you can control the agent from your phone:
398
+
399
+ ```
400
+ /model qwen3.5:122b → switch model
401
+ /voice → toggle TTS
402
+ /dream → enter dream mode
403
+ /listen → toggle voice input
404
+ /stats → show session metrics
405
+ /config → show current config
406
+ /bless → toggle blessed mode
407
+ /telegram status → check bridge status
408
+ ```
409
+
410
+ The command output is captured, ANSI-stripped, and sent back as a Telegram message. Skill invocations (e.g., `/ralph`, `/eval-agent`) are queued as tasks.
411
+
389
412
  ### Sub-Agent Architecture
390
413
 
391
414
  Each Telegram message spawns an independent `AgenticRunner` sub-agent. Sub-agent tool calls, status updates, and streaming tokens appear in the terminal waterfall view with `✈ @username` prefixes — so you can watch all Telegram conversations happening alongside your main work.
@@ -396,23 +419,86 @@ If a user sends another message while their sub-agent is still running, it's inj
396
419
 
397
420
  | Level | MaxTurns | Tools | Memory |
398
421
  |-------|----------|-------|--------|
399
- | **Admin** (`--admin`) | 30 | file read, grep, glob, memory r/w/search, web fetch/search | Full read + write |
400
- | **Public** (everyone else) | 8 | memory read/search, web fetch/search | Read-only |
422
+ | **Admin DM** (`--admin`, private chat) | 30 | All tools except shell (overridable) | Full read + write |
423
+ | **Admin Group** (admin in group chat) | 15 | Read-only + web + vision/OCR/transcription | Full read + write |
424
+ | **Public** (everyone else) | 8 | memory r/w (scoped), web fetch/search | Scoped per-chat |
401
425
 
402
- **Admin** users get the full agent experience they can ask the bot to read files, search the codebase, write to memory, and perform web research. The admin's sub-agent gets full project context injected.
426
+ **Admin DM** full agent experience in private chat. File read, grep, glob, memory, web research, all tools except shell (which can be unblocked via config).
403
427
 
404
- **Public** users get a lightweight assistant with safety guardrails. No file access, no shell, no code just web search, public memory, and general knowledge. The 10-point safety filter is always active.
428
+ **Admin Group** when the admin speaks in a group chat, the agent responds with read-only capabilities. No system-mutating tools (no shell, no file write, no code execution). Vision, OCR, transcription, and web tools are available for analyzing shared media and answering questions.
429
+
430
+ **Public** — lightweight assistant with safety guardrails. No file access, no shell, no code. Web search, scoped memory, and general knowledge only. Reply discretion active in groups.
405
431
 
406
432
  ### Streaming Responses
407
433
 
408
434
  While the sub-agent is working, users see:
409
435
  1. **Typing indicator** — "typing..." appears immediately and refreshes every 4 seconds until the response is ready
410
- 2. **Streaming draft** — via `sendMessageDraft` (Bot API 9.3+), partial responses stream to the user in real-time as the agent generates tokens. Falls back gracefully on older clients
411
- 3. **Final message** — committed via `sendMessage` when the agent completes
436
+ 2. **Admin live streaming** — a placeholder message is sent immediately, then progressively edited via `editMessageText` with accumulated content + intermediate states (tool calls, results, status updates). Admin sees `🔧 tool_name(...)` and `✔ tool_name: result` inline as the agent works
437
+ 3. **Markdown → HTML conversion** — all responses are automatically converted from GitHub-flavored Markdown to Telegram-compatible HTML (`<b>`, `<i>`, `<code>`, `<pre>`, `<s>`, `<a>`) with plaintext fallback
438
+ 4. **Final message** — committed via `editMessageText` (admin) or `sendMessage` (public) when the agent completes
439
+
440
+ ### Public User Isolation
441
+
442
+ Public users get **per-chat isolated memory** — each chat has its own scoped memory namespace (`telegram-{chatId}-{topic}`) so public users can store and retrieve facts about their conversation without accessing or polluting global agent memory. Public tools include: `memory_read`, `memory_write` (scoped), `memory_search`, `web_search`, `web_fetch`.
443
+
444
+ ### Context-Aware Tool Policy
445
+
446
+ Tools are gated per execution context. The system enforces strict separation between what's available in a terminal session versus a public Telegram group:
447
+
448
+ | Context | Default Tools | Notes |
449
+ |---------|--------------|-------|
450
+ | `terminal` | All tools | Wide open — shell, file read/write, everything |
451
+ | `telegram-admin-dm` | All except shell | Admin DM — full tools, shell blocked by default (overridable) |
452
+ | `telegram-admin-group` | Read-only + web + vision/OCR | Admin in public group — no system mutation tools |
453
+ | `telegram-public` | Memory r/w, web fetch/search | Public users — minimal safe tools only |
454
+ | `api` | All tools | API endpoint — configurable |
455
+
456
+ **System tools** (`shell`, `file_write`, `file_edit`, `file_read`, `file_patch`, `batch_edit`, `grep_search`, `glob_find`, `list_directory`, `code_sandbox`, `codebase_map`, `git_info`, etc.) are **never exposed** in public-facing contexts.
457
+
458
+ **User overrides** — customize tool availability via config (`~/.open-agents/config.json`):
459
+
460
+ ```json
461
+ {
462
+ "toolPolicies": {
463
+ "blockedTools": {
464
+ "shell": ["*"],
465
+ "web_crawl": ["telegram-public"]
466
+ },
467
+ "contextAllowlist": {
468
+ "telegram-admin-group": ["transcribe_file", "transcribe_url"]
469
+ }
470
+ }
471
+ }
472
+ ```
473
+
474
+ **Resolution logic**: blocked takes priority over allowed. If the allowed set is empty, all tools are available (minus blocked). If non-empty, only those tools pass through (minus blocked).
475
+
476
+ ### Group Chat Distinction
477
+
478
+ The bridge distinguishes between **private DMs** and **group/supergroup chats**, even for admin users:
479
+
480
+ - **Admin DM** → full tool access, live streaming via `editMessageText`, project context injected
481
+ - **Admin in group** → read-only tools + web + vision/OCR, no live streaming, concise responses
482
+ - **Public in group** → minimal safe tools, reply discretion active
483
+
484
+ **Reply discretion** — in group chats, the agent evaluates whether a message warrants a response. Casual greetings, messages directed at other users, and chatter that doesn't involve the bot are silently skipped (the agent returns `no_reply` as its summary). This prevents the bot from flooding group conversations with unnecessary responses.
485
+
486
+ ### Media Handling
487
+
488
+ Photos, audio, voice messages, video, video notes, and documents sent via Telegram are automatically downloaded and processed:
489
+
490
+ 1. **Download** — files are fetched via the Telegram `getFile` API and cached to `.oa/media-cache/`
491
+ 2. **Processing** — routed to the appropriate pipeline:
492
+ - Images → `vision` / `image_read` / `ocr` tools
493
+ - Audio/voice → `transcribe_file` tool
494
+ - Video/video notes → `transcribe_file` (audio track extraction)
495
+ - Documents → `pdf_to_text` / `ocr_pdf` for PDFs, `file_read` for text
496
+ 3. **Context injection** — processing results are prepended to the user's message as additional context for the sub-agent
497
+ 4. **Cache cleanup** — media files are cached for 30 minutes, then automatically deleted. Only metadata (filename, type, chat ID, timestamp, processing result summary) is persisted long-term per chat
412
498
 
413
499
  ### Rate Limit Handling
414
500
 
415
- The bridge automatically handles Telegram's rate limits (HTTP 429) with exponential backoff using the `retry_after` field. Draft sends are throttled to max 1 per second per chat.
501
+ The bridge automatically handles Telegram's rate limits (HTTP 429) with exponential backoff using the `retry_after` field. Live message edits are throttled to max 1 per second per chat.
416
502
 
417
503
  **Safety filter** — every public Telegram-sourced task is wrapped with strict safety instructions:
418
504
  - Never share private information, API keys, file paths, or system internals
@@ -423,6 +509,67 @@ The bridge automatically handles Telegram's rate limits (HTTP 429) with exponent
423
509
 
424
510
  **Combined with blessed mode** — `/full-send-bless` + `/telegram` creates a persistent, always-on agent that processes Telegram messages around the clock while keeping the model warm.
425
511
 
512
+ ## Emotion Engine — Affective State Modulation
513
+
514
+ The agent stack includes a real-time emotion system that modulates behavior based on an appraisal-based affective model. Built on Russell's circumplex model of affect, the engine maintains a continuous emotional state defined by two axes:
515
+
516
+ - **Valence** (-1 to +1): displeasure ↔ pleasure
517
+ - **Arousal** (0 to 1): calm ↔ energized
518
+
519
+ Every agent event (tool success/failure, task completion, errors, context pressure) is appraised and shifts the emotional state, which decays back toward a baseline over ~60 seconds. The emotional state modulates agent behavior:
520
+
521
+ | Quadrant | Valence | Arousal | Behavioral Effect |
522
+ |----------|---------|---------|-------------------|
523
+ | Excited/Manic | High+ | High | Bold action, creative solutions, fast iteration |
524
+ | Determined/Stressed | Low- | High | Intense focus, double-checking, persistence |
525
+ | Content/Calm | High+ | Low | Methodical approach, patient exploration |
526
+ | Subdued/Cautious | Low- | Low | Careful, deliberate, risk-averse |
527
+
528
+ ### Emotion Center (LLM-Generated Labels)
529
+
530
+ The emotion label and emoji displayed in the TUI are **not from a static list** — they are generated by the "emotion center," a dedicated LLM call with high temperature (0.9) that receives the current valence/arousal coordinates and freely chooses an evocative word and emoji. While guided toward face emojis (😊 😤 🤔 😰 🤩), the emotion center can diverge to animals (🦊), objects (🔥), or esoteric choices (🌊) at its own discretion.
531
+
532
+ ### TUI Status Bar
533
+
534
+ The current emotion is displayed in the status bar between the SNR indicator and the Exp (expert speed ratio):
535
+
536
+ ```
537
+ In: 1,234 | Out: 567 | Ctx: 8,192/131,072 | SNR: 85% | 🔥 exhilarated | Exp: 3.2x | Cost: $0.00
538
+ ```
539
+
540
+ ### Proactive Admin Outreach
541
+
542
+ When the Telegram bridge is active with `--admin`, the emotion engine can proactively message the admin:
543
+ - **Excitement threshold** (arousal ≥ 0.85, valence > 0.5): shares task completions and success streaks
544
+ - **Distress threshold** (valence ≤ -0.7, arousal > 0.6): signals consecutive failures that may need human guidance
545
+ - Outreach is rate-limited to at most once per 5 minutes
546
+
547
+ ### Momentum Effects
548
+
549
+ Consecutive outcomes amplify emotional shifts (modeled after PRISM's SDE snowball effect):
550
+ - 3+ consecutive successes → escalating excitement multiplier
551
+ - 2+ consecutive failures → escalating stress multiplier
552
+
553
+ ### Research Foundations
554
+
555
+ The emotion system is informed by peer-reviewed and preprint research:
556
+
557
+ 1. **Russell Circumplex Model** — Wu et al. "AI shares emotion with humans across languages and cultures" (arXiv:2506.13978, 2025). Confirms LLM emotion spaces are structurally congruent with the circumplex model; human emotion concepts can causally steer LLM affective states.
558
+
559
+ 2. **VIGIL EmoBank** — Cruz, "VIGIL: A Reflective Runtime for Self-Healing Agents" (arXiv:2512.07094, 2025). Persistent emotional state store with appraisal pipeline and decay policies; emotional state drives behavioral interventions.
560
+
561
+ 3. **EILS Homeostatic Signals** — Tiwari, "Emotion-Inspired Learning Signals" (arXiv:2512.22200, 2025). Bio-inspired curiosity/stress/confidence signals create closed-loop homeostatic regulation of exploration vs. exploitation.
562
+
563
+ 4. **Concurrent Modular Agent** — Maruyama et al. (arXiv:2508.19042, 2025). Practical realization of Minsky's Society of Mind theory with asynchronous LLM modules and shared global state.
564
+
565
+ 5. **Swarm Emotional Modulation** — Freire-Obregón (arXiv:2603.09963, 2026). Arousal drives commitment speed (exploitation pressure); valence drives risk tolerance in collective decision dynamics.
566
+
567
+ 6. **PRISM SDE** — Lu et al. (arXiv:2512.19933, 2025). Stochastic differential equations for continuous emotional evolution with personality-conditional action selection.
568
+
569
+ 7. **PsySET Benchmark** — Banayeeanzade et al. (arXiv:2510.04484, 2025). Prompting is effective for emotion steering; emotional states have systemic cross-domain effects on reasoning quality.
570
+
571
+ 8. **EmotionBench** — Huang et al. (arXiv:2308.03656, 2023). LLMs cannot maintain emotional state across turns implicitly — argues for explicit external mood state representation (which this engine implements).
572
+
426
573
  ## Listen Mode — Live Bidirectional Audio
427
574
 
428
575
  Listen mode enables real-time voice communication with the agent. Your microphone audio is captured, streamed through Whisper, and the transcription is injected directly into the input line — creating a hands-free coding workflow.