Commit graph

1313 commits

Author SHA1 Message Date
maxiaoyang
7129c97dd2 feat(agent): plumb sender ID through user message persistence
Connects the inbound SenderID, which was already carried end-to-end via
InboundContext to PromptBuildRequest, into the per-turn user message so
historical messages remember who said what.

- userPromptMessage gains a senderID parameter. Real human IDs are
  sanitized via SanitizeMessageName; synthetic triggers (cron,
  heartbeat, async:*) are filtered out via IsSystemSenderID so they
  do not surface as distinct users.

- pipeline_setup.go now passes ts.opts.Dispatch.SenderID() and uses
  AddFullMessage unconditionally. The previous AddMessage(role,
  content) shortcut for media-less turns silently dropped the new
  Name field, breaking history disambiguation.

- context.go (BuildMessagesFromPrompt) propagates req.SenderID onto
  the current-turn user message that goes to the LLM.

After this commit, sessions persist sender attribution and provider
adapters receive it on each user message. Adapters that consume Name
(OpenAI native field, Anthropic-style content prefix) land in
follow-up commits.

The existing "## Current Sender" block in buildDynamicContext is
unchanged; it continues to describe the latest speaker in the system
prompt while Name covers the per-message channel for history.

Refs #2702.
2026-04-29 21:02:59 +08:00
maxiaoyang
7c7d7146ef feat(messageutil): add IsSystemSenderID and ApplyUserNamePrefix helpers
Two more helpers needed for end-to-end multi-user attribution:

- IsSystemSenderID filters synthetic trigger sources (cron, heartbeat,
  async:* tool callbacks, system channel) so internal events do not
  surface as distinct human users in the conversation. Without this,
  cron-triggered messages would carry attribution like cron, producing
  a confusing [cron] [System: cron] ... double prefix on adapters that
  fall back to in-content rendering.

- ApplyUserNamePrefix renders msg.Name as a [name] prefix on user
  content for adapters whose APIs do not support a per-message author
  identity (Anthropic, Bedrock, OpenAI Responses). The persisted
  message is never mutated; only the wire payload carries the prefix.
  Tool result messages and non-user roles pass through unchanged.

These helpers are pure and independently testable; they will be wired
into the agent and provider adapters in subsequent commits.

Refs #2702.
2026-04-29 21:01:03 +08:00
maxiaoyang
d1e9bb6ae3 feat(messageutil): add SanitizeMessageName for OpenAI wire compliance
OpenAI's Chat Completions name field requires ^[a-zA-Z0-9_-]{1,64}$.
Real-world sender IDs (Discord alice#1234, numeric Telegram IDs, Slack
U07AB12C3DEF, free-form CLI names) often violate this, so a sanitizer
sits between the raw inbound ID and any wire payload.

Disallowed characters collapse into a single underscore, leading and
trailing underscores are trimmed, and the result is byte-safely
truncated to 64 (output is pure ASCII).

This helper will be wired into the agent pipeline in a later commit.

Refs #2702.
2026-04-29 20:59:21 +08:00
maxiaoyang
72005ae06c feat(protocol): add Name field to providers.Message
Adds an optional Name field on providers.Message so per-message sender
attribution can be carried through the persistence layer and onto the
wire. The field is JSON-tagged `name,omitempty`, so:

- the OpenAI Chat Completions wire format will be able to emit the
  native `name` field that disambiguates participants in multi-user
  conversations;
- session stores that round-trip messages via json.Marshal preserve
  the field with no extra plumbing;
- existing session files load cleanly with Name = "".

This is the schema-only change. Adapters and the agent pipeline are
updated in subsequent commits.

Refs #2702.
2026-04-29 20:54:11 +08:00
美電球
db1bc6a1f8
Merge pull request #2689 from afjcjsbx/fix/cron-session-key-propagation
fix(cron): propagate sessionKey to prevent duplicate tool responses
2026-04-28 23:03:09 +08:00
LC
9b109dc7a8
fix(serial_windows): remove unused import (#2697) 2026-04-28 16:19:59 +08:00
Guoguo
fc24676924
Add cross-platform serial tool support (#2673)
* feat(tools): add cross-platform serial hardware tool

* feat(config): wire serial tool into runtime and dashboard

* hardware/serial: tighten validation and error handling

* hardware/serial: improve unix cancellation and timeout polling

* hardware/serial: improve windows I/O handling

* hardware/serial: fix darwin cross-compilation build

* docs(design): summarize hardware support and serial limits

* build: keep go generate on host during cross builds

* onboard: drop unrelated go generate change from serial work

* style(tools): wrap serial lines for golines
2026-04-28 13:10:32 +08:00
SiYue-ZO
bd867a16cd style(tools): wrap serial lines for golines 2026-04-28 12:58:26 +08:00
SiYue-ZO
893e61dc51 hardware/serial: fix darwin cross-compilation build 2026-04-28 12:57:44 +08:00
SiYue-ZO
64e48163d0 hardware/serial: improve windows I/O handling 2026-04-28 12:57:25 +08:00
SiYue-ZO
1f0a5f4eda hardware/serial: improve unix cancellation and timeout polling 2026-04-28 12:57:09 +08:00
SiYue-ZO
338fa258b3 hardware/serial: tighten validation and error handling 2026-04-28 12:56:47 +08:00
SiYue-ZO
2114e1a53f feat(config): wire serial tool into runtime and dashboard 2026-04-28 12:56:27 +08:00
SiYue-ZO
0f52076762 feat(tools): add cross-platform serial hardware tool 2026-04-28 12:54:28 +08:00
LC
c44bd6138c
refactor(pico): unify message kind handling of tool_calls and thought (#2680)
* refactor(pico): unify message kind handling of tool_calls and thought

* fix(pico): add legacy compatibility for thought payload in Send method

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
2026-04-28 10:17:12 +08:00
afjcjsbx
0bb0fc429a fix(cron): propagate sessionKey to prevent duplicate tool responses 2026-04-27 13:17:25 +02:00
Mauro
ed687d62ae
fix(config): show precise malformed config diagnostics (#2415)
* fix(config): show precise malformed config diagnostics

* fix lint

* fix test
2026-04-27 09:45:52 +08:00
lc6464
d6b38c4236
fix(chat): update tool_calls structure and ensure kind is always set 2026-04-26 20:13:13 +08:00
lc6464
1acab59fc7
fix(tests): format error message 2026-04-26 19:48:22 +08:00
lc6464
bfc37b784e
fix(channels): bypass placeholder edits for thought and tool calls 2026-04-26 19:43:25 +08:00
lc6464
6d04d15ce0
fix(tool-feedback): dedupe duplicate content and keep full explanations 2026-04-26 00:40:55 +08:00
lc6464
5cd10b594a
feat(pico): add support for tool_calls in chat messages 2026-04-25 23:43:10 +08:00
美電球
41f4d95597
Merge pull request #2657 from lc6464/fix-deepseek-v4-thinking-history
fix(reasoning): persist canonical history for DeepSeek and web chat
2026-04-25 15:08:48 +08:00
Mauro
04b62745e4
Merge pull request #2664 from afjcjsbx/fix/mcp-http-session-lifecycle
fix(mcp): retry tool calls on lost HTTP sessions and fix client lifec…
2026-04-25 08:51:28 +02:00
lc6464
ae162a72b1
fix(message): ignore transient assistant thoughts in message count and history truncation 2026-04-25 12:26:28 +08:00
美電球
788f76f422
Merge pull request #2666 from afjcjsbx/fix/mcp-nil-arguments
fix(mcp): send empty object instead of null for tool
2026-04-25 11:38:48 +08:00
美電球
2f91cc0a80
Merge pull request #2660 from afjcjsbx/fix/tool-feedback-json-format
fix(tool-feedback): format tool args as JSON code blocks
2026-04-25 11:34:09 +08:00
美電球
caaad601af
Merge pull request #2656 from alexhoshina/prompt-layering
Prompt layering
2026-04-25 11:22:21 +08:00
afjcjsbx
9d8f0dc877 fix(mcp): send empty object instead of null for tool 2026-04-24 21:24:29 +02:00
afjcjsbx
8f8af0874d fix(mcp): retry tool calls on lost HTTP sessions and fix client lifecycle 2026-04-24 20:20:57 +02:00
Hoshina
9ca73b944f fix(agent): preserve prompt hook and cache semantics 2026-04-25 01:25:17 +08:00
afjcjsbx
94a6b0c0f5 fix(tool-feedback): format tool args as JSON code blocks 2026-04-24 18:07:48 +02:00
LC
979ff00cc3
fix(messageutil): remove dead code
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-24 22:16:18 +08:00
lc6464
bb0f983708
fix(reasoning): persist canonical history for DeepSeek and web chat 2026-04-24 21:45:41 +08:00
Hoshina
48d8952591 feat(agent): migrate tool prompts to capability slots 2026-04-24 19:36:46 +08:00
Mauro
8d51d306b3
Merge pull request #2641 from afjcjsbx/feat/mcp-cli
feat(mcp): add show, add, list, remove, test, edit cli commands
2026-04-24 13:06:34 +02:00
Hoshina
2e65b1be83 feat(agent): add structured prompt layering 2026-04-24 18:14:28 +08:00
BeaconCat
f334ac6d01
fix: treat PID=1 as stale in PID file singleton check, fix govet shadow, add .gitattributes (#2642)
- pid: When a container stops and leaves behind a PID file with PID 1
  on a shared volume, the host's init process (PID 1) passes the
  isProcessRunning check, blocking new gateway starts. Treat recorded
  PID 1 as always stale in both WritePidFile and ReadPidFileWithCheck.
  Added unit tests covering the PID=1 container leftover scenario.

- isolation: Fix govet shadow warning on platform_windows.go line 105
  where := shadows the outer err variable. Changed to = assignment.

- gitattributes: Enforce LF line endings for shell scripts to prevent
  CRLF issues when checking out on Windows (breaks Docker entrypoint).

Co-authored-by: BeaconCat <BeaconCat@users.noreply.github.com>
2026-04-24 15:26:34 +08:00
afjcjsbx
f4dbac0dcf fix(mcp): expand home paths for local stdio server commands 2026-04-24 07:47:26 +02:00
Junghwan
293477b02a
Keep launcher locale changes from mutating shared web-search routing (#2573)
The launcher wired UI language changes into a process-global backend
switch that changed auto web-search provider selection and the
reported current service for every handler in the same process.

This narrows the fix to the validated leak: remove backend sync from
frontend locale changes, drop the now-unused UI endpoint, and make
auto selection fall back to a stable default when the query itself
does not contain a script hint.

Constraint: Keep the patch small and mergeable without redesigning per-user preference storage
Rejected: Add per-user backend language state | larger scope than the validated bug and unclear maintainer preference
Rejected: Persist preferred language in config | still shares mutable state across clients of the same instance
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: If locale-aware provider routing is reintroduced later, scope it to explicit config or request context instead of package-global state
Tested: go test ./web/backend/api ./pkg/tools -count=1; pnpm lint; pnpm build
Not-tested: Full make check; live multi-browser manual launcher run after the backend endpoint removal
2026-04-24 13:45:25 +08:00
Mauro
9fc72c1fb3
feat(tool-feedback): add separate message mode for chat feedback (#2644)
* feat(tool-feedback): add separate message mode for chat feedback

* add parameter in conf
2026-04-24 11:49:41 +08:00
美電球
0d1b041d74
Merge pull request #2485 from afjcjsbx/fix/telegram-oauth-links
fix(telegram): preserve raw OAuth links in HTML rendering
2026-04-24 11:35:16 +08:00
美電球
0c0a582559
Merge pull request #2586 from kunalk16/fix-functions-deduplication
refactor(deduplication): functions deduplication in pkg/providers
2026-04-23 20:55:11 +08:00
wenjie
cac4f21746
fix(tools): improve web search provider fallback (#2629)
- centralize web search provider readiness and resolution logic
- fall back when the configured provider is unavailable or invalid
- allow native-search-capable models to use built-in search without the client tool
- simplify the tools page and add direct access to web search settings
- add backend, agent, and integration tests for the new selection behavior
2026-04-23 15:39:16 +08:00
Kunal Karmakar
7616470137 Revert deduplication 2026-04-23 05:50:38 +00:00
Kunal Karmakar
4ae11406d2 Deduplicate further functions 2026-04-23 05:50:37 +00:00
Kunal Karmakar
bc077db0ee Deduplicate ParseDataAudioURL function 2026-04-23 05:50:37 +00:00
Kunal Karmakar
e901e70c14 Fix linting 2026-04-23 05:47:58 +00:00
Kunal Karmakar
c71146b1d5 Functions deduplication 2026-04-23 05:47:58 +00:00
lxowalle
451db2f5d8
Feat(channels): unify animated tool feedback across chat channels and Pico (#2622)
* feat(channels): unify tool feedback animation across discord telegram and feishu

* fix(tool-feedback): unify fallback and single-message delivery

* fix(channels): finalize tool feedback in place

* fix ci

* feat: improve tool feedback

* fix review blockers in pico token cache and tool feedback

fix(provider): preserve function thought signatures

fix(feishu): recover tool feedback after edit fallback

* * delete dead code

* fix(pico): clean up tool feedback progress state

* fix ci

* fix(web): preserve tool feedback line breaks in chat

* fix(channels): preserve tool feedback progress state

fix(pico): preserve context usage when finalizing tool feedback

chore: record branch review pass

fix: preserve tool feedback finalization state

fix(web): handle pico history update fallback

* fix ci
2026-04-23 10:35:50 +08:00