feat(miniapp): give marketplace agent runs web research - #1956
Merged
bobleer merged 1 commit intoAug 1, 2026
Conversation
Marketplace MiniApps run under the strict runtime profile, and the host bridge forced `enableTools: false` on their hidden agent sessions. That switch is all-or-nothing, so it also removed WebSearch and WebFetch: the two marketplace Agentic MiniApps (Market Lens, 循天问命) could never look anything up, while the built-in PPT Live kept full tool access through the compatibility profile. Move the boundary from the frontend to the runtime. Agent turns now carry the app's runtime profile as `marketStrict` metadata, and strict runs resolve to a read-only research allowlist (WebSearch, WebFetch, the clock, and the deferred gateway pair) layered on top of the existing headless denials. The execution gate matches the effective tool name, so a deferred invocation cannot smuggle a denied tool past the allowlist. Built-in and compatibility MiniApps keep the wider headless tool set unchanged. `enable_tools` is persisted in the session config, so sessions created by earlier builds would stay tool-less on reuse. Reused MiniApp agent sessions now have their tool enablement re-synced with the current run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
BitFun 目前有三个 Agentic MiniApp:PPT Live、Market Lens、循天问命。其中只有 PPT Live 的 Agent 能联网调研,另外两个完全没有 WebSearch / WebFetch。
根因在框架侧,不在小应用自己:
useMiniAppBridge.ts对runtime_profile = market_strict的市场小应用在agent.ensureSession和agent.run两处硬编码了enableTools: false。这个开关是全有或全无的,关掉整个工具循环的同时也一并关掉了只读的联网调研能力。PPT Live 走的是compatibility档位,所以不受影响——其会话记录里能看到真实的 WebSearch / WebFetch 调用,而另外两个小应用的每个会话toolCallCount都是 0。改动
把安全边界从不可信的前端移到运行时后端:
marketStrict标记,只在严格档位序列化,内置小应用的 metadata 与既有版本逐字节一致。WebSearch/WebFetch/GetTime加上 deferred 网关对,叠加在既有 headless 禁用项之上。文件系统、命令行、宿主控制面一律碰不到。用白名单(而不是更长的黑名单)保证新注册的工具默认关闭。执行闸门比对的是 effective tool name,所以 deferred 调用无法绕过白名单。enable_tools是写死在会话配置里的,旧版本创建的会话复用时会永远没有工具。复用 MiniApp Agent 会话时现在会重新同步工具开关。验证
cargo test -p bitfun-agent-tools(103 passed)cargo test -p bitfun-product-domains --all-featurescargo test -p bitfun-core --lib(1743 passed)cargo check -p bitfun-desktop、cargo clippy -p bitfun-core -p bitfun-desktop --all-targets(改动文件无新增告警)pnpm run type-check:web、pnpm vitest run src/app/scenes/miniapps(15 files / 52 tests passed)pnpm run fmt:rs、pnpm run check:repo-hygiene新增回归测试覆盖:严格档位的工具白名单与 headless 禁用项叠加、运行时档位选择、metadata 标记、以及前端不再强制关闭工具循环。