picoclaw/pkg/agent
xiaoen 8034ee7be1 fix(agent): correct media token arithmetic and tool call double-counting
Two estimation bugs fixed:

1. Media tokens were added to the chars accumulator before the chars*2/5
   conversion, resulting in 256*2/5=102 tokens per item instead of 256.
   Fix: add media tokens directly to the final token count, bypassing
   the character-based heuristic.

2. estimateMessageTokens counted both tc.Name and tc.Function.Name for
   tool calls, but providers only send one (OpenAI-compat uses
   function.name, Anthropic uses tc.Name). Fix: count tc.Function.Name
   when Function is present, fall back to tc.Name only otherwise.

Also fix i18n hint text: "auto-detect" was misleading — the backend
uses a 4x max_tokens heuristic, not actual model detection.
2026-03-16 14:48:34 +08:00
..
context.go Merge pull request #1207 from afjcjsbx/feat/debug-mode-no-truncate 2026-03-10 17:13:44 +01:00
context_budget.go fix(agent): correct media token arithmetic and tool call double-counting 2026-03-16 14:48:34 +08:00
context_budget_test.go fix(agent): correct media token arithmetic and tool call double-counting 2026-03-16 14:48:34 +08:00
context_cache_test.go fix(agent): invalidate system prompt cache for global/builtin skills (#845) 2026-03-03 18:25:00 +08:00
context_test.go fix deepseek-chat bug (#1066) 2026-03-06 16:04:31 +08:00
instance.go refactor(agent): context boundary detection, proactive budget check, and safe compression 2026-03-16 14:48:32 +08:00
instance_test.go enable dupl check 2026-03-01 18:17:32 +11:00
loop.go refactor(agent): use Turn as the atomic unit for compression cut-off 2026-03-16 14:48:34 +08:00
loop_mcp.go Fix/Add warning tips for MCP initialization when no valid servers configured (#1497) 2026-03-13 16:43:00 +08:00
loop_media.go feat: expose local file paths for non-image media to enable agent file tools (#1516) 2026-03-14 12:09:11 +08:00
loop_test.go feat: expose local file paths for non-image media to enable agent file tools (#1516) 2026-03-14 12:09:11 +08:00
memory.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
mock_provider_test.go feat(fmt): Fix formatting 2026-02-19 22:05:15 +02:00
registry.go feat(session): integrate JSONL persistence into agent loop (#1170) 2026-03-10 15:14:09 +08:00
registry_test.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
steering.go feat(agent): steering (#1517) 2026-03-16 00:08:16 +08:00
steering_test.go feat(agent): steering (#1517) 2026-03-16 00:08:16 +08:00
thinking.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
thinking_test.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00