From 6851b9cd1e1d3e3632a82514293301f028987207 Mon Sep 17 00:00:00 2001 From: CXSforHPU <19511928573@163.com> Date: Mon, 30 Nov 2026 23:58:09 +0800 Subject: [PATCH] =?UTF-8?q?[ai/agent]=E8=A3=81=E5=89=AA=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20choice=EF=BC=8C=E5=90=AF=E7=94=A8=E5=90=8E?= =?UTF-8?q?=E6=89=8D=E6=98=BE=E7=A4=BA=E5=AD=90=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit skill、分层内存、运算工具、MQTT、device 框架、MCP 六组总开关从 bool 改成 choice(Disable 默认 / Enable 成员)。 - 默认选 Disable,最小内核配置不变 - 子选项包在 if 里,选 Disable 时不再出现在 menuconfig - Enable 成员沿用原符号名(device 工具仍是 PKG_AGENT_TOOL_DEVICE), SConscript 和文档无需改动 --- ai/Agent/Kconfig | 245 ++++++++++++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 90 deletions(-) diff --git a/ai/Agent/Kconfig b/ai/Agent/Kconfig index 41f59c81a9..5a5d209755 100644 --- a/ai/Agent/Kconfig +++ b/ai/Agent/Kconfig @@ -686,61 +686,81 @@ if PKG_USING_AGENT endmenu menu "Agent Skills Configuration" - config PKG_AGENT_SKILL_ENABLE - bool "Enable built-in skills" - default y + + choice PKG_AGENT_SKILL_MODE_SEL + prompt "Built-in skills" + default PKG_AGENT_SKILL_DISABLE help Compile the skill registry, the skill tool, and the embedded - Markdown catalog into firmware. Turn this off on MCUs without - room for the skill module; the sources are excluded entirely - and the system prompt gets no skill catalog. + Markdown catalog into firmware. Disabled by default so a fresh + configuration builds only the minimal core; the two options + below only show up after this is enabled. - The two options below are ignored when this is disabled. + config PKG_AGENT_SKILL_DISABLE + bool "Disable built-in skills" - config PKG_AGENT_SKILL_DIR - depends on PKG_AGENT_SKILL_ENABLE - string "Markdown skill directory" - default "skills" - help - Recursively embed .md files as const C strings at build time. - Relative paths are resolved from the Agent package directory; - absolute paths are also supported. Use UTF-8 Markdown files. - The relative path without .md is the skill name. - Override for one build with scons agent_skill_dir=. - Changes require rebuilding firmware; no runtime filesystem is needed. - - config PKG_AGENT_SKILL_EMBED - depends on PKG_AGENT_SKILL_ENABLE - string "Skills to embed" - default "*" - help - Selects which Markdown skills are compiled into firmware. - An asterisk (default) embeds every .md file found under the - skill directory. A comma-separated list embeds only those - names, for example "device,math". "none" or an empty value - embeds no skill content. - - Trimmed skills take no Flash space and are absent from the - skill catalog in the system prompt. A listed name that does - not exist stops the build, so typos do not silently drop a - skill. Rebuild firmware after changing this value. + config PKG_AGENT_SKILL_ENABLE + bool "Enable built-in skills" + help + Compile the skill registry, the skill tool, and the + embedded Markdown catalog into firmware. Turn this off on + MCUs without room for the skill module; the sources are + excluded entirely and the system prompt gets no skill + catalog. + endchoice + + if PKG_AGENT_SKILL_ENABLE + + config PKG_AGENT_SKILL_DIR + string "Markdown skill directory" + default "skills" + help + Recursively embed .md files as const C strings at build time. + Relative paths are resolved from the Agent package directory; + absolute paths are also supported. Use UTF-8 Markdown files. + The relative path without .md is the skill name. + Override for one build with scons agent_skill_dir=. + Changes require rebuilding firmware; no runtime filesystem is needed. + + config PKG_AGENT_SKILL_EMBED + string "Skills to embed" + default "*" + help + Selects which Markdown skills are compiled into firmware. + An asterisk (default) embeds every .md file found under the + skill directory. A comma-separated list embeds only those + names, for example "device,math". "none" or an empty value + embeds no skill content. + + Trimmed skills take no Flash space and are absent from the + skill catalog in the system prompt. A listed name that does + not exist stops the build, so typos do not silently drop a + skill. Rebuild firmware after changing this value. + endif endmenu menu "Agent Memory" - config PKG_AGENT_MEMORY_ENABLE - bool "Enable layered memory" - default n + choice PKG_AGENT_MEMORY_MODE_SEL + prompt "Layered memory" + default PKG_AGENT_MEMORY_DISABLE help MemGPT-style memory on top of the conversation context. Core memory is injected into every model request. Recall memory is searched with keywords from the latest user message and the top matches are appended after it. - The pool is static, no heap is used. Default sizes cost - about 8 KB of RAM: 8 core items and 32 recall items of - 192 bytes, plus a 1 KB injection buffer. When disabled - the module compiles out and all call sites become no-ops. + config PKG_AGENT_MEMORY_DISABLE + bool "Disable layered memory" + + config PKG_AGENT_MEMORY_ENABLE + bool "Enable layered memory" + help + The pool is static, no heap is used. Default sizes cost + about 8 KB of RAM: 8 core items and 32 recall items of + 192 bytes, plus a 1 KB injection buffer. When disabled + the module compiles out and all call sites become no-ops. + endchoice if PKG_AGENT_MEMORY_ENABLE @@ -831,6 +851,22 @@ if PKG_USING_AGENT menu "Agent Tools Configuration" + choice PKG_AGENT_TOOL_CALC_MODE_SEL + prompt "Arithmetic tools" + default PKG_AGENT_TOOL_CALC_DISABLE + help + Compile the three demo arithmetic tools: add, mul and + compare. They are only examples; a minimal build keeps + them out of firmware. Turn this on for smoke tests or when + the model should do simple calculations. + + config PKG_AGENT_TOOL_CALC_DISABLE + bool "Disable arithmetic tools" + + config PKG_AGENT_TOOL_CALC_ENABLE + bool "Enable arithmetic tools" + endchoice + config PKG_AGENT_TOOL_LOOP_MAX int "Max tool call rounds per request" default 6 @@ -849,9 +885,6 @@ if PKG_USING_AGENT menu "Agent Tool: Mqtt Client" - config PKG_AGENT_TOOL_MQTT_ENABLE - bool "Enable MQTT client tool" - select PKG_USING_PAHOMQTT # 工具依赖 paho 的 pipe 模式(UDP 模式不提供 publish/subscribe 接口)。 # 注意:PAHOMQTT_PIPE_MODE / PAHOMQTT_UDP_MODE 在 paho 的 Kconfig 里是 # 同一个 choice 的成员,select 对 choice 成员无效(kconfiglib 会报 @@ -859,34 +892,47 @@ if PKG_USING_AGENT # 原来那句 select PAHOMQTT_PIPE_MODE 实际不起作用。请在 paho menuconfig # 里手动确认 "MQTT mode" 选的是 Pipe mode;若选成 UDP, # tool_mqtt.h 会在编译期直接 #error 提示。 - default n + choice PKG_AGENT_TOOL_MQTT_MODE_SEL + prompt "MQTT client tool" + default PKG_AGENT_TOOL_MQTT_DISABLE help - Enable the MQTT tool set for the agent: - * mqtt_connect : connect to the broker (idempotent) - * mqtt_disconnect : disconnect from the broker, keeping the - subscription table so a later connect - re-subscribes automatically - * mqtt_publish : publish a command to a topic - (checks the connection first) - * mqtt_subscribe : subscribe/unsubscribe topics at runtime - (delivery mode: filter/auto/poll) - * mqtt_rule : threshold rules, only wake the agent when out of range - * mqtt_history : summarize recent messages/payloads + numeric - min/max/avg, so the agent can assess the recent - situation (read-only) - * mqtt_receive : consume buffered messages on demand - - Requires paho-mqtt in PIPE mode: select it manually in the - paho menuconfig ("MQTT mode" -> Pipe mode), it cannot be - selected from here because it is a choice member. - - IMPORTANT (paho side, must be set in the paho menuconfig): - * PKG_PAHOMQTT_SUBSCRIBE_HANDLERS >= PKG_AGENT_TOOL_MQTT_MAX_SUB_TOPICS - (default 4; with the paho default of 1 only one topic can be subscribed) - * RT_PKG_MQTT_THREAD_STACK_SIZE >= 8192 - (the paho worker opens "/dev/MQTTn" through DFS, whose path - resolution allocates ~12KB and needs stack; a 4KB stack - overflows it, corrupts heap metadata and hangs the system) + Let the agent talk to an MQTT broker through paho. The sub + menus below only show up after this is enabled. + + config PKG_AGENT_TOOL_MQTT_DISABLE + bool "Disable MQTT client tool" + + config PKG_AGENT_TOOL_MQTT_ENABLE + bool "Enable MQTT client tool" + select PKG_USING_PAHOMQTT + help + Enable the MQTT tool set for the agent: + * mqtt_connect : connect to the broker (idempotent) + * mqtt_disconnect : disconnect from the broker, keeping the + subscription table so a later connect + re-subscribes automatically + * mqtt_publish : publish a command to a topic + (checks the connection first) + * mqtt_subscribe : subscribe/unsubscribe topics at runtime + (delivery mode: filter/auto/poll) + * mqtt_rule : threshold rules, only wake the agent when out of range + * mqtt_history : summarize recent messages/payloads + numeric + min/max/avg, so the agent can assess the recent + situation (read-only) + * mqtt_receive : consume buffered messages on demand + + Requires paho-mqtt in PIPE mode: select it manually in the + paho menuconfig ("MQTT mode" -> Pipe mode), it cannot be + selected from here because it is a choice member. + + IMPORTANT (paho side, must be set in the paho menuconfig): + * PKG_PAHOMQTT_SUBSCRIBE_HANDLERS >= PKG_AGENT_TOOL_MQTT_MAX_SUB_TOPICS + (default 4; with the paho default of 1 only one topic can be subscribed) + * RT_PKG_MQTT_THREAD_STACK_SIZE >= 8192 + (the paho worker opens "/dev/MQTTn" through DFS, whose path + resolution allocates ~12KB and needs stack; a 4KB stack + overflows it, corrupts heap metadata and hangs the system) + endchoice if PKG_AGENT_TOOL_MQTT_ENABLE @@ -1138,15 +1184,22 @@ if PKG_USING_AGENT # 每个模块文件自己用 #ifdef PKG_AGENT_TOOL_DEVICE_XXX 包住全文,并用 # AGENT_TOOL_MODULE_EXPORT 登记到模块表,所以关掉某个模块 = 不编译该文件, # 注册表和工具列表里自然没有它,不需要改中心文件。 - config PKG_AGENT_TOOL_DEVICE - bool "Enable device framework tools" + choice PKG_AGENT_TOOL_DEVICE_MODE_SEL + prompt "Device framework tools" depends on RT_USING_DEVICE - default n + default PKG_AGENT_TOOL_DEVICE_DISABLE help Let the agent drive peripherals through the RT-Thread device framework. Turn on the generic layer (core) first, then pick the device classes the project actually has drivers for. + config PKG_AGENT_TOOL_DEVICE_DISABLE + bool "Disable device framework tools" + + config PKG_AGENT_TOOL_DEVICE + bool "Enable device framework tools" + endchoice + if PKG_AGENT_TOOL_DEVICE config PKG_AGENT_TOOL_DEVICE_CORE @@ -1234,24 +1287,36 @@ if PKG_USING_AGENT menu "Agent Tool: MCP Client" - config PKG_AGENT_TOOL_MCP_ENABLE - bool "Enable MCP client tools" - default n + choice PKG_AGENT_TOOL_MCP_MODE_SEL + prompt "MCP client tools" + default PKG_AGENT_TOOL_MCP_DISABLE help Let the agent talk to one MCP (Model Context Protocol) server - over Streamable HTTP. At agent startup the client runs the - initialize / notifications/initialized / tools/list handshake - and registers every remote tool into the agent tool table with - an "mcp_" prefix, so the model can call them like local tools. - - The server side lives in the package mcp/ directory: a bundled - HTTP server plus a stdio-to-HTTP bridge for the servers Windows - registers through the On-Device Registry (odr.exe list) and for - servers started from the command line, such as Windows-MCP - (CursorTouch/Windows-MCP), which drives the local desktop. - - If the server cannot be reached the agent still starts, just - without the remote tools. + over Streamable HTTP. The options below only show up after + this is enabled. + + config PKG_AGENT_TOOL_MCP_DISABLE + bool "Disable MCP client tools" + + config PKG_AGENT_TOOL_MCP_ENABLE + bool "Enable MCP client tools" + help + At agent startup the client runs the + initialize / notifications/initialized / tools/list + handshake and registers every remote tool into the agent + tool table with an "mcp_" prefix, so the model can call + them like local tools. + + The server side lives in the package mcp/ directory: a + bundled HTTP server plus a stdio-to-HTTP bridge for the + servers Windows registers through the On-Device Registry + (odr.exe list) and for servers started from the command + line, such as Windows-MCP (CursorTouch/Windows-MCP), + which drives the local desktop. + + If the server cannot be reached the agent still starts, + just without the remote tools. + endchoice if PKG_AGENT_TOOL_MCP_ENABLE