Commit Graph
255 Commits
Author SHA1 Message Date
Re-bin 9d0db072a3 fix: guard quoted home paths in shell tool 2026-03-11 15:43:04 +00:00
Re-bin 85609c99b3 Merge remote-tracking branch 'origin/main' into pr-1827 2026-03-11 15:32:52 +00:00
Re-bin 9fc74bde9a Merge remote-tracking branch 'origin/main' into pr-1874 2026-03-11 15:26:39 +00:00
Re-bin c72c2ce7e2 refactor: move generation settings to provider level, eliminate parameter passthrough 2026-03-11 09:47:04 +00:00
WhalerO 6ef7ab53d0 refactor: centralize tool call serialization in ToolCallRequest 2026-03-11 15:32:43 +08:00
WhalerO ed82f95f0c fix: preserve provider-specific tool call metadata for Gemini 2026-03-11 15:32:26 +08:00
ethanclaw 12104c8d46 fix(memory): pass temperature, max_tokens and reasoning_effort to memory consolidation
Fix issue #1823: Memory consolidation does not inherit agent temperature
and maxTokens configuration.

The agent's configured generation parameters were not being passed through
to the memory consolidation call, causing it to fall back to default values.
This resulted in the consolidation response being truncated before the
save_memory tool call was emitted.

- Pass temperature, max_tokens, reasoning_effort from AgentLoop to
  MemoryConsolidator and then to MemoryStore.consolidate()
- Forward these parameters to the provider.chat_with_retry() call

Fixes #1823
2026-03-11 14:22:33 +08:00
Re-bin ddccf25bb1 fix(subagent): preserve reasoning fields across tool turns
Share assistant message construction between the main agent and subagents, and add a regression test to keep reasoning_content and thinking_blocks in follow-up tool rounds.
2026-03-11 03:47:24 +00:00
Re-bin 1d611f9bf3 Merge remote-tracking branch 'origin/main' into pr-1848 2026-03-11 03:42:14 +00:00
Re-bin 62ccda43b9 refactor(memory): switch consolidation to token-based context windows
Move consolidation policy into MemoryConsolidator, keep backward compatibility for legacy config, and compress history by token budget instead of message count.
2026-03-10 19:55:06 +00:00
Re-bin 4784eb4128 merge origin/main into pr-1704 2026-03-10 18:09:15 +00:00
lailoo 2ffeb9295b fix(subagent): preserve reasoning_content in assistant messages
Subagent's _run_subagent() was dropping reasoning_content and
thinking_blocks when building assistant messages for the conversation
history. Providers like Deepseek Reasoner require reasoning_content on
every assistant message when thinking mode is active, causing a 400
BadRequestError on the second LLM round-trip.

Align with the main AgentLoop which already preserves these fields via
ContextBuilder.add_assistant_message().

Closes #1834
2026-03-11 00:47:09 +08:00
Re-bin b0a5435b87 refactor(llm): share transient retry across agent paths 2026-03-10 10:10:37 +00:00
Re-bin 46b31ce7e7 Merge remote-tracking branch 'origin/main' into pr-1512 2026-03-10 09:40:48 +00:00
suger-m 6c70154fee fix(exec): enforce workspace guard for home-expanded paths 2026-03-10 15:55:04 +08:00
Re-bin 4715321319 Merge branch 'main' into pr-1579 and tighten platform guidance 2026-03-08 16:39:37 +00:00
Re-bin ce9b516b11 Merge branch 'main' into pr-1579 2026-03-08 16:29:54 +00:00
Re-bin 5eb67facff Merge branch 'main' into pr-1728 and harden MCP tool cancellation handling 2026-03-08 16:01:06 +00:00
Re-bin 4e197dc18e Merge branch 'main' into pr-1728 2026-03-08 15:51:06 +00:00
Re-bin 7cbb254a8e fix: remove stale IDENTITY bootstrap entry 2026-03-08 15:39:40 +00:00
Alfredo ArenasandGitHub ed3b9c16f9 fix: handle CancelledError in MCP tool calls to prevent process crash
MCP SDK's anyio cancel scopes can leak CancelledError on timeout or
failure paths. Since CancelledError is a BaseException (not Exception),
it escapes both MCPToolWrapper.execute() and ToolRegistry.execute(),
crashing the agent loop.

Now catches CancelledError and returns a graceful error to the LLM,
while still re-raising genuine task cancellations from /stop.
Also catches general Exception for other MCP failures (connection
drops, invalid responses, etc.).

Related: #1055
2026-03-08 08:05:18 -06:00
VITOHJL 274edc5451 fix(compression): prefer provider prompt token usage 2026-03-08 17:25:59 +08:00
VITOHJL 1b16d48390 fix(loop): update _cumulative_tokens in _save_turn and preserve it in compression methods 2026-03-08 15:26:49 +08:00
VITOHJL a984e0df37 feat(loop): add history message count logging in compression 2026-03-08 15:23:55 +08:00
VITOHJL dbc518098e refactor: implement token-based context compression mechanism
Major changes:
- Replace message-count-based memory window with token-budget-based compression
- Add max_tokens_input, compression_start_ratio, compression_target_ratio config
- Implement _maybe_compress_history() that triggers based on prompt token usage
- Use _build_compressed_history_view() to provide compressed history to LLM
- Refactor MemoryStore.consolidate() -> consolidate_chunk() for chunk-based compression
- Remove last_consolidated from Session, use _compressed_until metadata instead
- Add background compression scheduling to avoid blocking message processing

Key improvements:
- Compression now based on actual token usage, not arbitrary message counts
- Better handling of long conversations with large context windows
- Non-destructive compression: old messages remain in session, but excluded from prompt
- Automatic compression when history exceeds configured token thresholds
2026-03-08 14:20:16 +08:00
Re-bin 515b3588af Merge main into pr-1482 2026-03-07 15:33:24 +00:00
Re-bin 43fc59da00 fix: hide internal reasoning in progress 2026-03-07 14:53:14 +00:00
VITOHJL cf76011c1a fix: hide reasoning_content from user progress updates 2026-03-07 17:09:59 +08:00
Re-bin c3f2d1b01d fix(tools): narrow parameter auto-casting 2026-03-07 05:28:12 +00:00
Barry WangandGitHub 81a8a1be1e Merge branch 'HKUDS:main' into feat/improve-tool-validation-tests 2026-03-06 15:42:26 +08:00
Re-bin 3a01fe536a refactor: move detect_image_mime to utils/helpers for reuse 2026-03-06 06:49:09 +00:00
Re-bin 91b3ccee96 Merge remote-tracking branch 'origin/main' into pr-1573 2026-03-06 06:41:00 +00:00
Re-bin fc0b38c304 fix(memory): improve warning message for empty/non-dict list arguments 2026-03-06 05:27:39 +00:00
nanobot-contributor 6fb4204ac6 fix(memory): handle list type tool call arguments
Some LLM providers return tool_calls[0].arguments as a list instead of
dict or str. Add handling to extract the first dict element from the list.

Fixes /new command warning: 'unexpected arguments type list'
2026-03-06 11:47:00 +08:00
VITOHJL 958c23fb01 chore: refine platform policy and memory SKILL docs 2026-03-05 23:57:43 +08:00
Re-bin d32c6f946c fix(telegram): pin ptb>=22.6, fix double progress, clean up stale hatch config 2026-03-05 15:17:30 +00:00
Re-bin b070ae5b2b Merge remote-tracking branch 'origin/main' into pr-1522 2026-03-05 15:05:26 +00:00
Re-bin b71c1bdca7 fix(mcp): hoist sse/http imports, annotate auto-detection heuristic, restore field comments 2026-03-05 14:44:45 +00:00
Re-bin 2306d4c11c Merge remote-tracking branch 'origin/main' into pr-1488 2026-03-05 14:35:02 +00:00
coldxiangyu 46192fbd2a fix(context): detect image MIME type from magic bytes instead of file extension
Feishu downloads images with incorrect extensions (e.g. .jpg for PNG files).
mimetypes.guess_type() relies on the file extension, causing a MIME mismatch
that Anthropic rejects with 'image was specified using image/jpeg but appears
to be image/png'.

Fix: read the first bytes of the image data and detect the real MIME type via
magic bytes (PNG: 0x89PNG, JPEG: 0xFFD8FF, GIF: GIF87a/GIF89a, WEBP: RIFF+WEBP).
Fall back to mimetypes.guess_type() only when magic bytes are inconclusive.
2026-03-05 20:29:10 +08:00
Barry Wang 667613d594 fix edge case casting and more test cases 2026-03-05 16:57:39 +08:00
Barry Wang 9e42ccb51e feat: auto casting tool params to match schema type 2026-03-05 16:57:39 +08:00
Sergio Sánchez Vallés 33f59d8a37 fix(agent): separate reasoning and tool hints to respect channel config 2026-03-05 00:45:15 +01:00
Sergio Sánchez Vallés c27d2b1522 fix(agent): prevent tool hints from overwriting reasoning in streaming drafts 2026-03-05 00:33:27 +01:00
Xubin RenandGitHub 4e9f08cafa Merge PR #1511: fix: add size limit to ReadFileTool to prevent OOM
fix: add size limit to ReadFileTool to prevent OOM
2026-03-05 01:12:40 +08:00
Xubin RenandGitHub a156a8ee93 Merge PR #1507: fix: guard validate_params against non-dict input
fix: guard validate_params against non-dict input
2026-03-05 00:36:29 +08:00
Sergio Sánchez Vallés 61f658e045 add reasoning content to on progress message 2026-03-04 12:11:18 +01:00
Kiplangatkorir d0c6479186 feat: add LLM retry with exponential backoff for transient errors
provider.chat() had no retry logic — a transient 429 rate limit,
502 gateway error, or network timeout would permanently fail the
entire message. For a system running cron jobs and heartbeats 24/7,
even a brief provider blip causes lost tasks.

Adds _chat_with_retry() that:
- Retries up to 3 times with 1s/2s/4s exponential backoff
- Only retries transient errors (429, 5xx, timeout, connection)
- Returns immediately on permanent errors (400, 401, etc.)
- Falls through to the final attempt if all retries exhaust
2026-03-04 11:20:50 +03:00
Kiplangatkorir ce65f8c11b fix: add size limit to ReadFileTool to prevent OOM
ReadFileTool had no file size check — reading a multi-GB file would
load everything into memory and crash the process. Now:
- Rejects files over ~512KB at the byte level (fast stat check)
- Truncates at 128K chars with a notice if content is too long
- Guides the agent to use exec with head/tail/grep for large files

This matches the protection already in ExecTool (10KB) and
WebFetchTool (50KB).
2026-03-04 11:15:45 +03:00
Kiplangatkorir edaf7a244a fix: handle invalid ISO datetime in CronTool gracefully
datetime.fromisoformat(at) raises ValueError for malformed strings,
which propagated uncaught and crashed the tool execution. Now catches
ValueError and returns a user-friendly error message instead.
2026-03-04 10:55:17 +03:00