Commit Graph
335 Commits
Author SHA1 Message Date
Xubin Ren c90e433057 fix(session): guard lossy migration by stored key 2026-06-27 16:52:54 +08:00
axelray-devandXubin Ren 00a907c493 fix(session): split safe_key and _storage_key to fix WebUI coupling (#4533) 2026-06-27 16:52:54 +08:00
axelray-devandXubin Ren cf2f589615 fix(session): prevent save from writing to legacy lossy path, add collision tests (#4533) 2026-06-27 16:52:54 +08:00
Xubin Ren 6a27c26257 test: cover non-stream duplicate tool call ids 2026-06-27 16:47:48 +08:00
r4sk1nandXubin Ren 47dcc61e9b test(agent): fix flaky test_keeps_n_most_recent by ensuring sequential mtimes 2026-06-27 16:29:31 +08:00
chengyongruandXubin Ren 3460ca3cb9 fix(agent): gate microcompaction on context pressure
Extract model-facing context governance from AgentRunner.

Only compact in-flight tool results when the model request is over budget, keep compacted IDs stable within a turn, and allow the newest result to be compacted as a last resort when it is the remaining source of overflow.
2026-06-27 11:04:41 +08:00
chengyongruandXubin Ren 9b45fc1172 fix(session): remove message time replay prefixes 2026-06-27 11:04:36 +08:00
axelray-devandXubin Ren 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
axelray-devandXubin Ren 6c880a6691 fix: advance dream cursor when Dream is disabled to prevent prompt bloat (#4242)
When dream.enabled is false, the Dream cron job never runs, so the
dream cursor (.dream_cursor) stays at its initial value (0). This
causes read_recent_history_for_prompt() to treat every history entry
as unprocessed, injecting the full chat history into every system
prompt and growing without bound.

Fix: fast-forward the dream cursor to the latest history entry at
gateway startup when Dream is disabled.
2026-06-25 22:53:10 +08:00
9354b80a6e fix(cli): show search engines (incl. Keenable) in onboard wizard
The onboard wizard dispatched field handlers by bare field name, so
WebSearchConfig.provider was hijacked by the LLM-provider handler and
showed LLM providers instead of search engines. Keenable was also never
wired into the CLI wizard when it landed in the WebUI.

- Add a single source of truth for selectable search providers
  (SEARCH_PROVIDER_OPTIONS in web.py); WebUI settings now import it.
- Add a WebSearchConfig-aware search-provider picker to the wizard and
  resolve handlers by (model type, field name) so the LLM and search
  provider fields no longer collide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 22:52:50 +08:00
chengyongruandXubin Ren 98dd883ce8 fix: buffer split reasoning wrapper deltas
maintainer edit: native reasoning streams can split <thinking> wrapper tags across chunks. Buffer the stream and emit only cleaned incremental reasoning so raw partial tags do not reach WebUI.
2026-06-24 15:45:34 +08:00
ZhouandXubin Ren 596bf5398c test: cover empty thinking marker streaming 2026-06-24 15:45:34 +08:00
ZhouandXubin Ren 523bb928bf fix: normalize thinking tags in reasoning output 2026-06-24 15:45:34 +08:00
chengyongruandXubin Ren 0e9861558a fix: keep duplicate id repair in Anthropic provider
maintainer edit: move duplicate tool_use history repair out of AgentRunner and into Anthropic message conversion, reusing the OpenAI-compatible queue-mapping approach locally without broadening the shared runner path.
2026-06-24 10:21:48 +08:00
chengyongruandXubin Ren 853aecdb97 fix: preserve duplicate-id tool calls
maintainer edit: remap duplicate tool_use/tool_call ids instead of dropping later calls, so Anthropic-compatible providers that reuse ids for distinct parallel tool calls keep all requested work while still sending unique ids.
2026-06-24 10:21:48 +08:00
Teddy YanandXubin Ren 6b8e832ba5 fix: address PR review comments - rename _dedup to _dedupe and fix ID storage consistency 2026-06-24 10:21:48 +08:00
6689e2d377 fix(providers): dedupe tool_use ids to prevent Anthropic 400s
Anthropic rejects any request where two tool_use blocks share an id
("messages.N.content.M: tool_use ids must be unique"). A mis-assembled
stream could surface the same tool_use block twice in one assistant turn;
the runner persisted it verbatim, so the malformed message was re-sent on
every subsequent turn and permanently bricked the session — the agent
silently stopped replying.

Fix at two layers:
- AnthropicProvider._parse_response: drop duplicate tool_use ids (keep
  first) as the response enters nanobot, so corruption is never persisted.
- AgentRunner._dedup_tool_calls: a new context-governance pass that dedupes
  assistant tool_calls and tool results by id before each send, healing any
  history that was already corrupted.

Add regression tests covering both the dedup and the no-op fast path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 10:21:48 +08:00
Xubin Ren fbaa85117b fix: close MCP stdio transports from agent task 2026-06-22 18:59:50 +08:00
Xubin Ren 351aabd512 fix: polish onboard wizard keyboard navigation 2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 9b52202f4a fix: make quick start rollback on websocket failure
maintainer edit: stage Quick Start edits on a draft config so declining WebSocket/password setup cannot leave saveable provider defaults behind. Align beginner WebUI docs with the password-protected setup.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren fca1f2ad02 fix: secure quick start webui setup
Add Quick Start endpoint choices for subscription plan providers, require explicit WebSocket confirmation, and require a WebUI password when enabling the WebSocket channel. Update docs to route Quick Start users through the WebUI instead of agent -m.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren e5294002ed fix: broaden quick start provider setup
Drive Quick Start provider choices from the provider registry instead of a short allowlist. Clean up parenthetical wizard labels and keep the beginner docs in sync.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren eb14720381 fix: ask for quick start model id
Remove automatic Quick Start model discovery. Users now explicitly enter the model ID after choosing the provider and API key, and incomplete Quick Start input does not leave partial provider config behind.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren da225fc24e fix: fetch openai quick start models
Use OpenAI's SDK default base URL for Quick Start model discovery without writing that default into the saved provider config.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 71631f9ab0 fix: ask provider in quick start
Maintainer edit: replace Quick Start key/base detection with an explicit provider-first flow. Users choose the provider that issued the API key, paste the key, and only custom OpenAI-compatible setups ask for a base URL.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 2319b660e6 fix: make quick start provider neutral
Maintainer edit: restart the Quick Start flow around an API-key-first path without recommending OpenRouter or DeepSeek. Detect unique key prefixes locally, fall back to a user-provided base URL, and only fetch models from that approved URL.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren ed3a8f64d8 fix: use deepseek for quick start onboarding
Maintainer edit: restart the Quick Start default around a mainland-friendly provider instead of making OpenRouter the first-run dependency. Update wizard copy, default preset, focused tests, and beginner docs to use DeepSeek with the current deepseek-v4-flash model.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 0e9b136315 fix: streamline quick start onboarding flow
Maintainer edit: continue the wizard simplification pass by making Quick Start save after the API key path, hiding save/summary actions until they are needed, removing failed-key side effects, and aligning beginner docs with the local WebUI path.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren fa5f7f5b88 fix: make onboarding api-key first
Maintainer edit: collapse the first-run wizard to an API-key-only Quick Start and move lower-frequency provider, model, channel, gateway, and tool settings behind Advanced Settings.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 1dbec3da50 fix: simplify beginner quick start
Maintainer edit: reduce the default onboarding path to a recommended local WebUI setup that only asks for an OpenRouter key, while keeping the detailed provider/channel flow available for advanced setup.
2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 9c7d1c9507 Use channel login in onboarding wizard 2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren db68fc1c09 Use provider registry in quick start 2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren f9f5a19910 Route WebUI quick start through channel config 2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren 0097488eed Keep quick start channels opt-in 2026-06-22 13:04:05 +08:00
chengyongruandXubin Ren fc7971b3b6 Improve onboard wizard setup flow 2026-06-22 13:04:05 +08:00
Xubin Ren dbf3c4b245 feat(sdk): expand Python runtime controls 2026-06-21 16:55:23 +08:00
Xubin Ren a81c5e704a fix(memory): reject negative history cursors 2026-06-21 13:05:57 +08:00
Stellar鱼andXubin Ren be058c0922 fix(memory): keep history cursor monotonic 2026-06-21 13:05:57 +08:00
yorkhellenandXubin Ren 33638417be fix(session): delete_session also removes legacy path files to prevent history revival
SessionManager._load() migrates sessions from the legacy directory
(~/.nanobot/sessions/) to the workspace path, but delete_session only
checked the workspace path. A user deleting a session could therefore
see its history come back the next time the session was loaded.

- delete_session now attempts to unlink both paths
- returns True if at least one file was removed
- added regression tests: legacy-only, both-paths, and no-revival
2026-06-19 21:07:47 +08:00
Xubin Ren bbd7bbd7f5 fix(mcp): avoid relying on progress notification root shape 2026-06-19 14:59:48 +08:00
yu-xin-candXubin Ren f9511049c4 fix(mcp): ignore malformed progress notifications 2026-06-19 14:59:48 +08:00
nanobot-contributorandXubin Ren c2c47f7a03 fix(fallback): treat empty API choices as fallbackable error
When the primary model (e.g. DeepSeek during peak hours) returns an empty
choices response with HTTP 200, the error carries no status code or
structured error metadata. The existing _FALLBACK_ERROR_TOKENS had no
matching token, so _should_fallback() returned False and fallback models
were never tried.

Changes:
- Add 'empty' token to _FALLBACK_ERROR_TOKENS so 'Error: API returned
  empty choices.' text matches the fallback path
- Set error_kind='empty' in openai_compat_provider when returning
  the empty-choices error, making the classification explicit
- Add test coverage for both text-only and error_kind matching paths

Fixes: glebov reported primary never falls back when DeepSeek returns
       empty responses
2026-06-19 14:59:44 +08:00
chengyongruandXubin Ren 42ce294665 fix: preserve internal tool write scopes
Maintainer edit: keep capability-specific allowed_dir boundaries active even when the outer workspace scope is full access, and cover Dream plus ordinary full-access filesystem behavior.
2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 15f218e918 fix: enforce exact Dream memory file writes
maintainer edit: Dream write tools used file paths as directory roots, so a missing canonical memory file could be treated as a parent directory. Add exact-file allowlist support and keep skills/ as the only Dream write directory.
2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 732992df4f Clarify filesystem workspace write policy 2026-06-18 00:03:26 +08:00
chengyongruandXubin Ren 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
chengyongruandXubin Ren ef6da0a94e Fix my tool model preset switching 2026-06-18 00:03:13 +08:00
chengyongruandXubin Ren 8ecc2d69c4 fix: log primary model error before fallback 2026-06-18 00:02:49 +08:00
chengyongruandXubin Ren 4c5e340186 feat(memory): enable idle auto compact by default 2026-06-17 00:48:06 +08:00