Commit Graph

66 Commits

Author SHA1 Message Date
Sergio Sánchez Vallés
d019ff06d2 Merge branch 'main' into fix/test-failures 2026-03-04 20:07:58 +01:00
Sergio Sánchez Vallés
e032faaeff Merge branch 'main' of upstream/main into fix/test-failures 2026-03-04 20:04:00 +01:00
chengyongru
88d7642c1e test: fix test failures from refactored cron and context builder
- test_context_prompt_cache: Update test to reflect merged runtime
  context and user message (commit ad99d5a merged them into one)
- Remove test_cron_commands.py: cron add CLI command was removed
  in commit c05cb2e (unified scheduling via cron tool)
2026-03-04 17:13:25 +01:00
Sergio Sánchez Vallés
c64fe0afd8 fix(tests): resolve failing tests on main branch
- Unskip matrix logic by adding missing deps (matrix-nio, nh3, mistune)
- Update matrix tests for 'allow_from' default deny security change
- Fix asyncio typing keepalive leak in matrix tests
- Update context prompt cache assert after runtime message merge
- Fix flaky cron service test with mtime sleep
- Remove obsolete test_cron_commands.py testing deleted CLI commands
2026-03-04 16:53:07 +01:00
chengyongru
bb8512ca84 test: fix test failures from refactored cron and context builder
- test_context_prompt_cache: Update test to reflect merged runtime
  context and user message (commit ad99d5a merged them into one)
- Remove test_cron_commands.py: cron add CLI command was removed
  in commit c05cb2e (unified scheduling via cron tool)
2026-03-04 20:49:02 +08:00
Re-bin
03b83fb79e fix(agent): skip empty multimodal user entries after runtime-context strip 2026-03-03 05:13:17 +00:00
yzchen
dba93ae83a cron: reload jobs store on each timer tick 2026-03-02 11:19:45 +08:00
yzchen
2fc16596d0 fix(feishu): parse post wrapper payload for rich text messages 2026-03-01 02:17:10 +08:00
Re-bin
8410f859f7 refactor: use WeakValueDictionary for consolidation locks — auto-cleanup, no manual pop 2026-02-28 08:26:55 +00:00
Re-bin
05e0d271fc Merge remote-tracking branch 'origin/main' into pr-1286 2026-02-28 08:07:07 +00:00
fengxiaohu
7229d86bb3 fix(shell): parse full Windows absolute paths in workspace guard 2026-02-27 21:46:46 +08:00
Xubin Ren
e86cfcde22 Merge PR #1200 to update heartbeat tests to match two-phase tool-call architecture
fix: update heartbeat tests to match two-phase tool-call architecture
2026-02-27 18:10:35 +08:00
Re-bin
ec8dee802c refactor: simplify message tool suppress and inline consolidation locks 2026-02-27 02:39:38 +00:00
Re-bin
29e6709e26 refactor: simplify message tool suppress — bool check instead of target tracking 2026-02-27 02:27:18 +00:00
Re-bin
ac1c40db91 Merge remote-tracking branch 'origin/main' into pr-1206 2026-02-27 02:17:04 +00:00
Re-bin
84f2f3c316 Merge remote-tracking branch 'origin/main' into pr-420 2026-02-26 02:48:21 +00:00
Re-bin
cdbede2fa8 refactor: simplify /stop dispatch, inline commands, trim verbose docstrings 2026-02-25 17:04:08 +00:00
chengyongru
fafd8d4eb8 fix(agent): only suppress final reply when message tool sends to same target
A refactoring in commit 132807a introduced a regression where the final
response was silently discarded whenever the message tool was used,
regardless of the target. This restored the original logic from PR #832
that only suppresses the final reply when the message tool sends to the
same (channel, chat_id) as the original message.

Changes:
- message.py: Replace _sent_in_turn: bool with _turn_sends: list[tuple]
  to track actual send targets, add get_turn_sends() method
- loop.py: Check if (msg.channel, msg.chat_id) is in sent_targets before
  suppressing final reply. Also move the "Response to" log after the
  suppress check to avoid misleading logs.
- Add unit tests for the suppress logic

This ensures:
- Email sent via message tool → Feishu still gets confirmation
- Message tool sends to same Feishu chat → No duplicate (suppressed)
2026-02-26 00:32:48 +08:00
Re-bin
149f26af32 Merge branch 'main' into pr-1180 2026-02-25 16:16:18 +00:00
Re-bin
d55a850357 refactor: simplify runtime context injection — drop JSON/dedup, keep untrusted tag 2026-02-25 16:13:48 +00:00
Elliot Lee
19a5efa89e fix: update heartbeat tests to match two-phase tool-call architecture
HeartbeatService was refactored from free-text HEARTBEAT_OK token
matching to a structured two-phase design (LLM tool call for
skip/run decision, then execution). The tests still used the old
on_heartbeat callback constructor and HEARTBEAT_OK_TOKEN import.

- Remove obsolete test_heartbeat_ok_detection test
- Update test_start_is_idempotent to use new provider+model constructor
- Add tests for _decide() skip path, trigger_now() run/skip paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 07:47:52 -08:00
coldxiangyu
2466b8b843 feat: /stop cancels spawned subagents via session tracking
- SubagentManager tracks _session_tasks: session_key -> {task_id, ...}
- cancel_by_session() cancels all subagents for a session
- SpawnTool passes session_key through to SubagentManager
- /stop response reports subagent cancellation count
- Cleanup callback removes from both _running_tasks and _session_tasks

Builds on #1179
2026-02-25 17:53:54 +08:00
coldxiangyu
3c12efa728 feat: extensible command system + task-based dispatch with /stop
- Add commands.py with CommandDef registry, parse_command(), get_help_text()
- Refactor run() to dispatch messages as asyncio tasks (non-blocking)
- /stop is an 'immediate' command: handled inline, cancels active task
- Global processing lock serializes message handling (safe for shared state)
- _pending_tasks set prevents GC of dispatched tasks before lock acquisition
- _dispatch() registers/clears active tasks, catches CancelledError gracefully
- /help now auto-generated from COMMANDS registry

Closes #849
2026-02-25 17:51:00 +08:00
rickthemad4
87a2084ee2 feat: add untrusted runtime context layer for stable prompt prefix 2026-02-24 16:38:29 +00:00
rickthemad4
56b9b33c6d fix: stabilize system prompt for better cache reuse 2026-02-24 14:18:50 +00:00
Re-bin
c6b933df4a Merge remote-tracking branch 'origin/main' into pr-1077 2026-02-24 11:38:38 +00:00
Re-bin
b9eb9d4963 Merge remote-tracking branch 'origin/main' into pr-1061 2026-02-24 11:22:01 +00:00
chengyongru
91e13d91ac fix(email): allow proactive sends when autoReplyEnabled is false
Previously, `autoReplyEnabled=false` would block ALL email sends,
including proactive emails triggered from other channels (e.g., asking
nanobot on Feishu to send an email).

Now `autoReplyEnabled` only controls automatic replies to incoming
emails, not proactive sends. This allows users to disable auto-replies
while still being able to ask nanobot to send emails on demand.

Changes:
- Check if recipient is in `_last_subject_by_chat` to determine if
  it's a reply
- Only skip sending when it's a reply AND auto_reply_enabled is false
- Add test for proactive send with auto_reply_enabled=false
- Update existing test to verify reply behavior
2026-02-24 04:27:14 +08:00
alairjt
3eeac4e8f8 Fix: handle non-string tool call arguments in memory consolidation
Fixes #1042. When the LLM returns tool call arguments as a dict or
JSON string instead of parsed values, memory consolidation would fail
with "TypeError: data must be str, not dict".

Changes:
- Add type guard in MemoryStore.consolidate() to parse string arguments
  and reject unexpected types gracefully
- Add regression tests covering dict args, string args, and edge cases
2026-02-23 13:59:49 -03:00
Re-bin
6f4d1c2cdc merge origin/main into pr-1039, adopt HEARTBEAT_OK in-check and on_notify 2026-02-23 13:57:28 +00:00
yzchen
bfdae1b177 fix(heartbeat): make start idempotent and check exact OK token 2026-02-23 13:56:37 +08:00
Alexander Minges
494fa8966a refactor(matrix): use milliseconds for typing timing constants 2026-02-21 20:45:09 +01:00
Alexander Minges
de5104ab2a fix(matrix): keep typing indicator during progress updates 2026-02-21 20:44:51 +01:00
Alexander Minges
e8a4671565 test: remove message tool media test (message.py changes out of scope) 2026-02-20 18:06:13 +01:00
Alexander Minges
705d5738e3 feat(matrix): reply in threads with fallback relations
Propagate Matrix thread metadata from inbound events and attach
m.relates_to
(rel_type=m.thread, m.in_reply_to, is_falling_back=true) to outbound
messages
including attachments. Add tests for thread metadata and thread replies.
2026-02-20 18:03:26 +01:00
Alexander Minges
6a40665753 feat(matrix): support outbound attachments via message tool
- extend message tool with optional media paths for channel delivery

- switch Matrix uploads to stream providers and handle encrypted-room payloads

- add/expand tests for message tool media forwarding and Matrix upload edge cases
2026-02-20 18:02:40 +01:00
Alexander Minges
d4d87bb4e5 fix(matrix): block outbound media when maxMediaBytes is zero 2026-02-20 18:02:15 +01:00
Alexander Minges
a28ae51ce9 fix(matrix): handle matrix-nio upload tuple response 2026-02-20 18:02:14 +01:00
Alexander Minges
97cb85ee0b feat(matrix): add outbound media uploads and unify media limits with maxMediaBytes
- Use OutboundMessage.media for Matrix file/image/audio/video sends
- Apply effective media limit as min(m.upload.size, maxMediaBytes)
- Rename matrix config key maxInboundMediaBytes -> maxMediaBytes (no legacy fallback)
2026-02-20 18:02:13 +01:00
Alexander Minges
10de3bf329 refactor(matrix): use base media event filter for callbacks
- Replaces the explicit media event tuple with MATRIX_MEDIA_EVENT_FILTER
  based on
  media base classes: (RoomMessageMedia, RoomEncryptedMedia).
- Keeps MatrixMediaEvent as the static typing alias for media-specific
  handlers.
- Removes MatrixInboundEvent and uses RoomMessage in mention-related
  logic.
- Adds regression tests for:
  - callback registration using MATRIX_MEDIA_EVENT_FILTER
  - ensuring RoomMessageText is not matched by the media filter.
2026-02-20 17:58:37 +01:00
Alexander Minges
566ad1dfc7 feat(matrix): make e2ee configurable with enabled default 2026-02-20 17:57:10 +01:00
Alexander Minges
8b3171ca2b fix(matrix): include empty m.mentions in outgoing messages 2026-02-20 17:56:24 +01:00
Alexander Minges
ca66ddb0bf feat(matrix): refresh typing indicator while processing 2026-02-20 17:56:15 +01:00
Alexander Minges
a482a89df6 feat(matrix): support inbound media attachments 2026-02-20 17:56:11 +01:00
Alexander Minges
6be7368a38 fix(matrix): sanitize formatted html with nh3 2026-02-20 17:55:59 +01:00
Alexander Minges
9b14869cb1 feat(matrix): support inline markdown html for url and super/subscript 2026-02-20 17:55:13 +01:00
Alexander Minges
cc5cfe6847 test(matrix): cover mention policy and sender filtering 2026-02-20 17:55:09 +01:00
Alexander Minges
3200135f4b test(matrix): cover formatted body and markdown fallback 2026-02-20 17:54:42 +01:00
Alexander Minges
840ef7363f test(matrix): cover typing indicator lifecycle 2026-02-20 17:54:29 +01:00
Alexander Minges
b721f9f37d test(matrix): cover response callbacks and graceful shutdown 2026-02-20 17:52:34 +01:00