Files
Arvin Xu 9bdc3b0474 feat: improve agent context injection (skills discovery, device optimization, prompt cleanup) (#13021)
*  feat: inject all installed skills into <available_skills> for AI discovery

Previously, only skills explicitly added to the agent's plugins list appeared
in <available_skills>. Now all installed skills are exposed so the AI can
discover and activate them via activateSkill.

Changes:
- Frontend: use getAllSkills() instead of getEnabledSkills(plugins)
- Backend: pass skillMetas through createOperation → RuntimeExecutors → serverMessagesEngine
- Add skillsConfig support to serverMessagesEngine

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: use DB + builtin skills for available_skills instead of provider manifests

lobehubSkillManifests are tool provider manifests (per-provider, containing
tool APIs), not skill metadata. Using them for <available_skills> incorrectly
showed provider names (e.g. "Arvin Xu") as skills.

Now fetches actual skills from AgentSkillModel (DB) + builtinSkills for correct
<available_skills> injection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 💄 style: use XML structure for online-devices in system prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: extract online-devices prompt to @lobechat/prompts package

Move device XML prompt generation from builtin-tool-remote-device into
the shared prompts package for reusability and consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

*  test: add failing tests for Remote Device suppression when auto-activated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ️ perf: suppress Remote Device tool when device is auto-activated

When a device is auto-activated (single device in IM/Bot or bound device),
the Remote Device management tool (listOnlineDevices, activateDevice) is
unnecessary — saves ~500 tokens of system prompt + 2 tool functions.

- Add autoActivated flag to deviceContext
- Move activeDeviceId computation before tool engine creation
- Disable Remote Device in enableChecker when autoActivated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* update system role

* update system role

* ♻️ refactor: use agentId instead of slug for OpenAPI responses model field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: use JSON round-trip instead of structuredClone in InMemoryAgentStateManager

structuredClone fails with DataCloneError when state contains non-cloneable
objects like DOM ErrorEvent (from Neon DB WebSocket errors).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: only inject available_skills when tools are enabled

Restore plugins guard to prevent skills injection when tool use is
disabled (plugins is undefined), fixing 28 test failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

*  test: update system message assertions for skills injection

Use stringContaining instead of exact match for system message content,
since available_skills may now be appended after the date.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 00:35:18 +08:00

16 lines
297 B
JSON

{
"name": "@lobechat/builtin-tool-remote-device",
"version": "1.0.0",
"private": true,
"exports": {
".": "./src/index.ts"
},
"main": "./src/index.ts",
"dependencies": {
"@lobechat/prompts": "workspace:*"
},
"devDependencies": {
"@lobechat/types": "workspace:*"
}
}