403 Commits

Author SHA1 Message Date
chengyongru
5794d481c3 refactor(agent): remove MCP runtime context provider 2026-07-12 00:35:17 +08:00
chengyongru
2eb7398f34 fix(agent): close runtime context persistence gaps 2026-07-12 00:35:17 +08:00
chengyongru
f75d3519db feat(agent): add persistent runtime context providers 2026-07-12 00:35:17 +08:00
chengyongru
7f8c3453e1 refactor(agent): gate sustained goals behind explicit /goal
Replace the legacy long-goal skill contract with command-scoped goal tools and runtime guidance. Keep goal state durable across continuations while restricting create and replace mutations to explicit user /goal turns.
2026-07-12 00:35:17 +08:00
Xubin Ren
edf78e7054 fix(mcp): keep transport cleanup in owner tasks 2026-07-11 11:45:20 +08:00
flyzstu
f3d1b9ca2d fix(mcp): defer stale stack cleanup during reconnect 2026-07-11 11:45:20 +08:00
chengyongru
21f58cbabf refactor(agent): make resolver sole runtime owner 2026-07-10 17:54:34 +08:00
chengyongru
c9d3e74342 refactor(agent): require runtime for consolidation 2026-07-10 17:54:34 +08:00
chengyongru
af85c356b8 refactor(agent): capture subagent runtime before spawn 2026-07-10 17:54:34 +08:00
chengyongru
198fd9f869 refactor(agent): capture runtime at turn admission 2026-07-10 17:54:34 +08:00
chengyongru
b4f069800e refactor(agent): make runner consume required runtime 2026-07-10 17:54:34 +08:00
chengyongru
cb03d2c748 refactor(agent): snapshot generation without provider mutation 2026-07-10 17:54:34 +08:00
chengyongru
42d7ad34a4 refactor(agent): unify request context routing 2026-07-10 17:54:34 +08:00
chengyongru
bb3b449e09 refactor(agent): capture original user text per turn 2026-07-10 17:54:34 +08:00
chengyongru
8559458258 refactor(agent): add turn hook factories 2026-07-08 21:02:12 +08:00
chengyongru
a52a88455b refactor(agent): extract turn hook assembly 2026-07-08 21:02:12 +08:00
chengyongru
3f33ff3143 chore: remove unused dead code 2026-07-07 15:41:27 +08:00
chengyongru
34535b4e7c fix(webui): hide subagent backfill payloads 2026-07-02 14:36:23 +08:00
chengyongru
acb0e853ff refactor(trigger): share automation turn delivery 2026-07-02 13:32:46 +08:00
chengyongru
f32007c83f fix(trigger): defer local triggers until session idle 2026-07-02 13:32:46 +08:00
chengyongru
55b550ee01 fix(trigger): hide external trigger inputs 2026-07-02 13:32:46 +08:00
chengyongru
5f4cfbcb16 refactor(bus): type outbound runtime events 2026-07-01 20:17:00 +08:00
chengyongru
4726ca0478 fix(restart): add explicit restart mode 2026-06-30 15:21:14 +08:00
chengyongru
57f0c859fc refactor(context): trim replay cap plumbing 2026-06-29 14:23:55 +08:00
chengyongru
40282e3b74 fix(context): scale replay cap with context window 2026-06-29 14:23:55 +08:00
chengyongru
dacc699293 fix(config): retire max messages setting 2026-06-29 14:23:55 +08:00
chengyongru
c8638dee46 fix(context): raise max messages fallback cap
Treat max_messages as a last-resort replay guard now that consolidation and idle auto-compact own normal history reduction. Raising the default avoids frequent sliding-window prefix churn in moderate conversations without adding a new cache-policy knob.
2026-06-29 14:23:55 +08:00
chengyongru
9b45fc1172 fix(session): remove message time replay prefixes 2026-06-27 11:04:36 +08:00
axelray-dev
851a0ff50c fix: make subagent fail_on_tool_error configurable (#4198)
Add fail_on_tool_error to AgentDefaults and wire it through
AgentLoop -> SubagentManager -> AgentRunSpec.

Previously hardcoded to True in SubagentManager._run_subagent.
Now configurable via config.json with default True for backward
compatibility. When set to False, subagents can retry on minor
tool errors instead of immediately failing.

Changes:
- nanobot/config/schema.py: add fail_on_tool_error field (default True)
- nanobot/agent/subagent.py: accept and forward fail_on_tool_error
- nanobot/agent/loop.py: pass config through to SubagentManager
- tests/agent/test_subagent.py: add regression test

Signed-off-by: axelray-dev <110029405+axelray-dev@users.noreply.github.com>
2026-06-25 22:53:36 +08:00
Xubin Ren
fbaa85117b fix: close MCP stdio transports from agent task 2026-06-22 18:59:50 +08:00
Xubin Ren
dbf3c4b245 feat(sdk): expand Python runtime controls 2026-06-21 16:55:23 +08:00
Xubin Ren
f4cc001410 refactor(sdk): pass run hooks explicitly 2026-06-21 15:59:28 +08:00
michaelxer
a19725bc57 docs: add note about ephemeral guard and per-call hooks contextvar
Document that SDK callers always go through run() → process_direct(ephemeral=False),
so per_call hooks are intentionally excluded from ephemeral turns per chengyongru
review feedback.
2026-06-21 15:59:28 +08:00
michaelxer
345ef80571 fix: update facade tests for contextvar hooks + fix ephemeral guard
The test_run_populates_tools_used_across_iterations,
test_run_populates_final_messages, and
test_run_user_hooks_still_fire_alongside_capture tests were reading
bot._loop._extra_hooks directly in their fake_process_direct mocks,
but the contextvar change moved per-call hooks to _per_call_hooks.

Also fixes the ephemeral guard: per_call hooks should not be used in
ephemeral mode (the original code incorrectly applied them regardless).
2026-06-21 15:59:28 +08:00
michaelxer
0bb1b0b3c2 fix(sdk): use contextvars for per-call hooks to prevent concurrent run() race
Nanobot.run() previously mutated the shared self._loop._extra_hooks
attribute under a try/finally. When two run() calls with different
session_keys execute concurrently, they overwrite each other's hook
lists — the second call saves the first call's hooks as 'prev', and
the finally block restores stale state.

Use a contextvars.ContextVar instead, which is per-task in asyncio.
This gives each concurrent run() call its own hook list without
changing any function signatures. Falls back to self._extra_hooks
when no per-call hooks are set (non-SDK usage).
2026-06-21 15:59:28 +08:00
chengyongru
fc635377bc fix: avoid replaying older long turns
Treat the current live user message as the replay boundary for normal user turns, while keeping user-turn extension for history and consolidation paths that need it. Add regression coverage for the user-triggered long tool-turn case.
2026-06-18 00:03:22 +08:00
Xubin Ren
09962895fb fix(session): preserve user turns in replay history 2026-06-18 00:03:22 +08:00
04cb
d75f80437c fix(api): don't re-persist user turn on empty-response retry (#4079)
The non-streaming retry called process_direct again with the same
content, persisting a duplicate user turn. Pass persist_user_message=False
so the retry recovers a response without re-recording the user message.
2026-06-16 21:31:26 +08:00
chengyongru
27d869d3cc fix(agent): refresh goal continuation context 2026-06-16 11:19:24 +08:00
Xubin Ren
dac4e39bcf
Merge PR #4299: feat(cron): bind scheduled automations to sessions
feat(cron): bind scheduled automations to sessions
2026-06-13 00:07:55 +08:00
chengyongru
d72d0102d9 style: trim orphan toolcall comments
maintainer edit: keep the invariant comments in production code but remove repeated issue background from tests.
2026-06-13 00:05:03 +08:00
chengyongru
33e6da14d8 fix: drop tool results missing call ids
maintainer edit: treat tool messages without tool_call_id as orphaned during session persistence so malformed results cannot survive into history.
2026-06-13 00:05:03 +08:00
tangtaizhong666
eb25df9b49 fix(session): never persist tool results without a declared tool call 2026-06-13 00:05:03 +08:00
tangtaizhong666
2ebf7e2eef fix(session): keep placeholder for tool results filtered to empty 2026-06-13 00:05:03 +08:00
chengyongru
a50b3ac0f2 fix: harden cron session automation flows 2026-06-12 18:13:25 +08:00
chengyongru
af8192dc38 refactor: move bound cron execution out of gateway 2026-06-12 15:50:36 +08:00
chengyongru
80524e9e88 refactor: bind cron jobs to origin sessions 2026-06-12 14:00:53 +08:00
chengyongru
271b3651d7 refactor: use cron turn naming internally 2026-06-12 11:57:35 +08:00
chengyongru
d9d481bc15 refactor: centralize cron session metadata keys 2026-06-12 11:43:23 +08:00
chengyongru
0ff8cd0cb3 fix: honor unified session for webui automations 2026-06-12 10:19:12 +08:00