Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
195333e
feat: extract sandbox runtimes from core
zouyonghe May 9, 2026
252ccd0
fix(dashboard): restore sandbox management UI
zouyonghe May 9, 2026
92017fb
fix: align sandbox dashboard behavior and defaults
zouyonghe May 9, 2026
3ffbb15
feat(agent): add sandbox lifecycle tools in sandbox mode
zouyonghe May 9, 2026
d7bfb2f
fix(dashboard): clarify sandbox status and release flow
zouyonghe May 9, 2026
3b93de3
fix(sandbox): refine dashboard controls and merge upstream
zouyonghe May 9, 2026
6d0c934
fix(ci): stabilize sandbox tests and formatting
zouyonghe May 9, 2026
d4eca5f
fix(sandbox): harden dashboard access and docs
zouyonghe May 9, 2026
7204f2f
fix(test): skip sandbox schema checks when plugins are absent
zouyonghe May 9, 2026
4b7a01c
docs: add sandbox runtime plugin guide
zouyonghe May 9, 2026
c20ce99
docs: clarify sandbox config override source
zouyonghe May 9, 2026
449c1b7
docs: make sandbox plugin guide developer focused
zouyonghe May 9, 2026
211de97
docs: move sandbox runtime guide out of config docs
zouyonghe May 9, 2026
f2f0cff
fix: address sandbox provider review feedback
zouyonghe May 9, 2026
56b166b
fix(sandbox): restore manager-backed skill sync
zouyonghe May 9, 2026
871c28d
fix: address sandbox provider runtime leaks and edge cases
zouyonghe May 9, 2026
a24939e
refactor(sandbox): unify provider lifecycle, tool registration and sk…
zouyonghe May 9, 2026
5744856
docs(protocol): recommend accepting plugin_config in __init__
zouyonghe May 9, 2026
ce2425f
fix(sandbox): persist force-unregister cleanup, unify create lifecycl…
zouyonghe May 9, 2026
b427ad6
fix(sandbox): invoke on_sandbox_created only after lease is acquired
zouyonghe May 9, 2026
1155f86
fix(sandbox): ensure on_sandbox_created hook fires for all creation p…
zouyonghe May 9, 2026
16ef42d
fix(sandbox): observer path semantics, hook concurrency, dashboard mo…
zouyonghe May 9, 2026
21f7c59
fix(sandbox): add require_lease to observer, fix dashboard monitoring…
zouyonghe May 9, 2026
b9828e0
fix(dashboard): allow shell to bypass lease check like screenshot
zouyonghe May 9, 2026
21e1e34
feat(sandbox): add complete lifecycle state machine
zouyonghe May 9, 2026
14a5d12
feat(dashboard): add lifecycle status display and action guards
zouyonghe May 9, 2026
26f2882
fix(sandbox): defer dashboard create lifecycle updates
zouyonghe May 9, 2026
dbc3c9b
style: format computer client
zouyonghe May 9, 2026
3e660e4
fix(prompt): prefer reusing default sandbox
zouyonghe May 9, 2026
e617bb0
docs(sandbox): rename lease wording to occupancy
zouyonghe May 9, 2026
323d8e3
fix(sandbox): support persistent reconnect in core
zouyonghe May 10, 2026
5d9440f
fix(sandbox): separate reconnect from create
zouyonghe May 10, 2026
a094bdb
fix(dashboard): load sandbox providers dynamically
zouyonghe May 10, 2026
01bb63a
fix(sandbox): revive persistent sandboxes on switch
zouyonghe May 10, 2026
e6a82fe
fix(sandbox): restore persistent sandboxes on startup
zouyonghe May 10, 2026
673b4db
fix(sandbox): reconcile persistent records on startup
zouyonghe May 10, 2026
6abd463
fix(sandbox): address review findings
zouyonghe May 10, 2026
c034268
fix(sandbox): harden lifecycle and access controls
zouyonghe May 10, 2026
83147ee
fix(sandbox): address remaining review feedback
zouyonghe May 10, 2026
66455cb
fix(sandbox): prefer configured provider in dashboard
zouyonghe May 10, 2026
b63b3d4
fix(sandbox): improve persistent recovery and visibility
zouyonghe May 10, 2026
f2366b4
fix(sandbox): reuse current session sandbox for tools
zouyonghe May 10, 2026
1d1887a
fix(sandbox): release current lease across providers
zouyonghe May 10, 2026
c71679f
fix(core): stop lifecycle on interrupted startup
zouyonghe May 10, 2026
17f2200
fix(sandbox): expose occupied sandboxes to agents
zouyonghe May 10, 2026
8750b58
fix(sandbox): allow switching to idle sandboxes
zouyonghe May 10, 2026
b72bbff
fix(sandbox): address review security findings
zouyonghe May 10, 2026
a68eb64
fix(sandbox): support shared idle pool leases
zouyonghe May 10, 2026
01d73e7
fix(sandbox): close persistent booters on unregister
zouyonghe May 10, 2026
09a0df7
fix(sandbox): scope tools to the active provider
zouyonghe May 10, 2026
faade71
fix(sandbox): prefer the current bound provider
zouyonghe May 10, 2026
b3b0a9e
fix(sandbox): remove temporary sandboxes on startup
zouyonghe May 10, 2026
a4e80e0
fix(shutdown): shield core cleanup on ctrl-c
zouyonghe May 10, 2026
d5d1724
fix(shutdown): await sandbox provider cleanup
zouyonghe May 10, 2026
670aa4a
fix(shutdown): clean live sandboxes without registry records
zouyonghe May 10, 2026
7cc9ebb
fix(shutdown): preserve persistent sandboxes on exit
zouyonghe May 10, 2026
c5b2f93
fix(sandbox): restore persistent sandboxes asynchronously
zouyonghe May 10, 2026
663b1f9
fix(shutdown): harden lifecycle stop path
zouyonghe May 10, 2026
37b4efd
revert(shutdown): drop generic ctrl-c hardening
zouyonghe May 10, 2026
c73df1a
fix(sandbox): remove embedded provider config metadata
zouyonghe May 10, 2026
28d6b98
feat(sandbox): expose provider discovery and selection
zouyonghe May 10, 2026
6e011b3
fix(shutdown): clean managed sandboxes on restart
zouyonghe May 11, 2026
5d3c627
Merge remote-tracking branch 'upstream/master' into feat/generic-sand…
zouyonghe May 11, 2026
cd1526d
docs: refine Chinese sandbox wording
zouyonghe May 11, 2026
9a517df
fix: tighten sandbox lock and provider binding
zouyonghe May 11, 2026
3384c15
test: cover current sandbox provider binding
zouyonghe May 11, 2026
cb7e9de
fix: keep sandbox caches and leases consistent
zouyonghe May 11, 2026
81d16fc
fix: ignore stale sandbox provider bindings
zouyonghe May 11, 2026
92bb74f
fix: align sandbox idle and boot recovery
zouyonghe May 11, 2026
c8ca040
fix: harden sandbox startup and takeover behavior
zouyonghe May 11, 2026
c9eb7fd
style: format sandbox manager
zouyonghe May 11, 2026
d50c7c1
fix: harden sandbox cleanup and retention updates
zouyonghe May 11, 2026
8a2a0fa
test: generalize sandbox provider fixtures
zouyonghe May 11, 2026
9a28411
fix: poll dashboard sandbox destroy completion
zouyonghe May 11, 2026
b8516e8
fix: guard against duplicate creating sandboxes
zouyonghe May 11, 2026
8f99b90
docs: polish sandbox migration guides
zouyonghe May 11, 2026
07e632c
docs: focus sandbox migration on config mapping
zouyonghe May 11, 2026
968ab27
fix: isolate sandbox skills and preserve download filenames
zouyonghe May 11, 2026
cb6b3d7
fix: serialize sandbox skill sync
zouyonghe May 11, 2026
f7ce657
fix: update sandbox sync test helper
zouyonghe May 11, 2026
c0e4a0a
fix: rename sandbox driver label
zouyonghe May 11, 2026
f123427
fix: bound sandbox idle cleanup retries
zouyonghe May 11, 2026
f203c70
docs: update sandbox driver guide
zouyonghe May 11, 2026
7b71bf6
test: align sandbox plugin defaults
zouyonghe May 11, 2026
bbf64e6
fix: allow builtin tool reloads
zouyonghe May 12, 2026
c63d989
Merge remote-tracking branch 'upstream/master' into feat/generic-sand…
zouyonghe May 12, 2026
47b4595
fix: stabilize sandbox tool reloads
zouyonghe May 12, 2026
11ded6f
fix: refine sandbox timeout lifecycle
zouyonghe May 12, 2026
09c5fba
docs: clarify sandbox timeout hints
zouyonghe May 12, 2026
85c589e
fix: format sandbox times for agent tools
zouyonghe May 12, 2026
a760860
fix: use configured lease timeout for takeover
zouyonghe May 12, 2026
f9809c9
fix: stabilize sandbox lifecycle cleanup
zouyonghe May 12, 2026
dfa722c
test: align sandbox lifecycle expectations
zouyonghe May 12, 2026
726337f
fix: keep sandbox destroy responsive
zouyonghe May 12, 2026
3455f01
fix: use backend sandbox create status
zouyonghe May 12, 2026
774cf8c
fix: align deferred sandbox lifecycle scheduling
zouyonghe May 12, 2026
e22562f
test: stabilize sandbox lifecycle waits
zouyonghe May 12, 2026
11dc8eb
chore: merge upstream master
zouyonghe May 12, 2026
76dc9b3
feat: let agents manage sandbox retention
zouyonghe May 13, 2026
42d0f5c
fix: filter sandbox provider tools in plugin tool fix
zouyonghe May 13, 2026
882bc06
fix: hide provider sandbox tools until selected
zouyonghe May 13, 2026
07831be
fix: label and expose sandbox provider tools
zouyonghe May 13, 2026
9157b82
fix: close persistent sandboxes on cleanup
zouyonghe May 13, 2026
463be57
chore: merge upstream master
zouyonghe May 13, 2026
6e5d7c5
fix: keep sandbox config migration provider agnostic
zouyonghe May 13, 2026
c64ab90
fix: preserve sandbox lifecycle on rename
zouyonghe May 13, 2026
6ec8c6e
feat: add member sandbox permissions
zouyonghe May 13, 2026
0d9267f
fix: localize sandbox limit errors
zouyonghe May 13, 2026
47ef767
fix: shorten docker sandbox errors
zouyonghe May 15, 2026
2d4aecf
fix: keep sandbox errors provider-owned
zouyonghe May 15, 2026
6acdcb9
chore: merge upstream master
zouyonghe May 17, 2026
cdc7b28
fix: harden sandbox lifecycle contracts
zouyonghe May 18, 2026
8b35cf6
fix: register sandbox provider tools once
zouyonghe May 18, 2026
9aed839
fix: expose sandbox occupancy status
zouyonghe May 18, 2026
5bf843a
fix: approve dashboard build scripts
zouyonghe May 18, 2026
63db021
fix: preserve provider default persistent sandboxes
zouyonghe May 18, 2026
b6028d6
fix: keep new sandboxes temporary by default
zouyonghe May 18, 2026
2f436a0
fix: keep unconfirmed persistent sandbox records
zouyonghe May 18, 2026
39e5363
fix: mark persistent sandbox recovery as restoring
zouyonghe May 18, 2026
6703577
fix: pass sandbox ids into provider connect metadata
zouyonghe May 18, 2026
58663df
fix: defer persistent sandbox restore until startup completes
zouyonghe May 18, 2026
431b9e4
fix: handle sandbox config errors without tracebacks
zouyonghe May 18, 2026
bb91357
fix: clean sandbox console cwd markers
zouyonghe May 18, 2026
366949b
fix: hide sandbox console cwd history markers
zouyonghe May 18, 2026
2f2f0ba
fix: suppress repeated shell tool notices
zouyonghe May 19, 2026
eac6c5a
Merge upstream/master into PR 8093
zouyonghe May 21, 2026
3ee33f5
fix: pass plugin context when renewing sandbox lease
zouyonghe May 25, 2026
9a0dc8c
Merge branch 'AstrBotDevs:master' into feat/generic-sandbox-core
zouyonghe May 31, 2026
0e311eb
fix: preserve failed sandbox boot records
zouyonghe Jun 1, 2026
f2d09d6
fix: prune temporary sandbox records on startup
zouyonghe Jun 1, 2026
981f017
fix: unregister plugin builtin tools on reload
zouyonghe Jun 1, 2026
4fd58bf
test: expect temporary sandbox startup pruning
zouyonghe Jun 1, 2026
4c9a723
Merge upstream/master into feat/generic-sandbox-core
zouyonghe Jun 1, 2026
7c11651
style: format dashboard config route
zouyonghe Jun 1, 2026
7b17397
fix: prune invalid provider source models
zouyonghe Jun 1, 2026
2d104a4
fix: release expired sandbox leases in listings
zouyonghe Jun 2, 2026
784af97
fix: upload aiocqhttp file messages via file actions
zouyonghe Jun 2, 2026
1194d8b
fix: fallback aiocqhttp file segments
zouyonghe Jun 2, 2026
e7d6d49
Merge branch 'AstrBotDevs:master' into feat/generic-sandbox-core
zouyonghe Jun 4, 2026
ee374ef
fix(dashboard): update mdi icon subset
zouyonghe Jun 4, 2026
408fe11
fix: retry provider stats on sqlite lock
zouyonghe Jun 4, 2026
7281fe7
fix: harden sandbox lifecycle review issues
zouyonghe Jun 4, 2026
cf9221b
Merge branch 'AstrBotDevs:master' into feat/generic-sandbox-core
zouyonghe Jun 4, 2026
288baf2
fix: harden sandbox cleanup and tool scoping
zouyonghe Jun 4, 2026
6334718
fix: clear unavailable sandbox booter config
zouyonghe Jun 4, 2026
379915d
fix: address sandbox review follow-ups
zouyonghe Jun 5, 2026
5817faf
fix: address sandbox review edge cases
zouyonghe Jun 5, 2026
e28f315
fix: restore sandbox status on cancelled revive
zouyonghe Jun 5, 2026
956b0e1
fix: harden sandbox dashboard mutations
zouyonghe Jun 5, 2026
07633f5
fix: preserve extended sandbox leases
zouyonghe Jun 5, 2026
04fb342
docs: clarify sandbox setup and leases
zouyonghe Jun 5, 2026
1d32739
Merge remote-tracking branch 'upstream/master' into feat/generic-sand…
zouyonghe Jun 5, 2026
21a830c
docs: link sandbox driver plugins
zouyonghe Jun 5, 2026
bc8ae9e
docs: clarify sandbox plugin prerequisite
zouyonghe Jun 5, 2026
ec667f9
docs: recommend plugin panel for sandbox drivers
zouyonghe Jun 5, 2026
f1a7dd5
Merge remote-tracking branch 'upstream/pr/8093' into pr-8093-merged-m…
Jun 7, 2026
674d5a2
Merge branch 'AstrBotDevs:master' into feat/generic-sandbox-core
zouyonghe Jun 8, 2026
66515df
Merge remote-tracking branch 'upstream/master' into feat/generic-sand…
zouyonghe Jun 9, 2026
9c3c9df
fix: harden sandbox health fallback
zouyonghe Jun 9, 2026
5bb5a82
Merge remote-tracking branch 'origin/feat/generic-sandbox-core' into …
zouyonghe Jun 9, 2026
e3f57e0
Merge remote-tracking branch 'upstream/master' into pr-8093-review
zouyonghe Jun 10, 2026
4be7bae
fix: harden sandbox dashboard and rollback handling
zouyonghe Jun 10, 2026
31b6354
refactor: extract sandbox dashboard helpers
zouyonghe Jun 10, 2026
3e49827
refactor: consolidate sandbox tools
zouyonghe Jun 10, 2026
4bcc94e
feat: expose sandbox lease metadata
zouyonghe Jun 10, 2026
f3109f8
docs: clarify sandbox lease renewal
zouyonghe Jun 10, 2026
04b8e67
merge: resolve upstream master conflicts
zouyonghe Jun 10, 2026
3c990b0
test: prevent CUA-specific screenshot tool exposure
zouyonghe Jun 10, 2026
8840238
fix: refresh current sandbox provider metadata
zouyonghe Jun 10, 2026
4f6faef
fix: clear idle cleanup state on give up
zouyonghe Jun 10, 2026
e32039f
fix: clear current sandbox when lease expires
zouyonghe Jun 11, 2026
67c3fba
docs: align sandbox lease expiry wording
zouyonghe Jun 11, 2026
c758a06
style: format sandbox manager
zouyonghe Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ GenieData/
.worktrees/

dashboard/bun.lock
docs/plans/
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ AstrBot 是一个开源的一站式 Agentic 个人和群聊助手,可在 QQ、
3. 🤖 支持接入 Dify、阿里云百炼、Coze 等智能体平台。
4. 🌐 多平台,支持 QQ、企业微信、飞书、钉钉、微信公众号、Telegram、Slack 以及[更多](#支持的消息平台)。
5. 📦 插件扩展,已有 1000+ 个插件可一键安装。
6. 🛡️ [Agent Sandbox](https://docs.astrbot.app/use/astrbot-agent-sandbox.html) 隔离化环境,安全地执行任何代码、调用 Shell、会话级资源复用
6. 🛡️ [Agent Sandbox](https://docs.astrbot.app/use/astrbot-agent-sandbox.html) 提供隔离沙盒环境,支持安全执行代码、调用 Shell,并在会话内复用资源
7. 💻 WebUI 支持。
8. 🌈 Web ChatUI 支持,ChatUI 内置代理沙盒、网页搜索等
8. 🌈 Web ChatUI 支持,内置 Agent Sandbox、网页搜索等能力
9. 🌐 国际化(i18n)支持。

<br>
Expand Down
4 changes: 4 additions & 0 deletions astrbot/core/agent/runners/tool_loop_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class ToolLoopAgentRunner(BaseAgentRunner[TContext]):
REPEATED_TOOL_NOTICE_L1_THRESHOLD = 3
REPEATED_TOOL_NOTICE_L2_THRESHOLD = 4
REPEATED_TOOL_NOTICE_L3_THRESHOLD = 5
REPEATED_TOOL_NOTICE_EXEMPT_TOOL_NAMES = frozenset({"astrbot_execute_shell"})
REPEATED_TOOL_NOTICE_L1_TEMPLATE = (
"\n\n[SYSTEM NOTICE] By the way, you have executed the same tool "
"`{tool_name}` {streak} times consecutively. Double-check whether another "
Expand Down Expand Up @@ -667,6 +668,9 @@ def _track_tool_call_streak(self, tool_name: str) -> int:
return self._same_tool_streak

def _build_repeated_tool_call_guidance(self, tool_name: str, streak: int) -> str:
if tool_name in self.REPEATED_TOOL_NOTICE_EXEMPT_TOOL_NAMES:
return ""

if streak < self.REPEATED_TOOL_NOTICE_L1_THRESHOLD:
return ""

Expand Down
90 changes: 66 additions & 24 deletions astrbot/core/astr_agent_tool_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from astrbot.core.astr_main_agent_resources import (
BACKGROUND_TASK_RESULT_WOKE_SYSTEM_PROMPT,
)
from astrbot.core.computer.sandbox_tool_binding import tool_available_in_runtime
from astrbot.core.cron.events import CronMessageEvent
from astrbot.core.message.components import Image
from astrbot.core.message.message_event_result import (
Expand All @@ -31,9 +32,6 @@
from astrbot.core.provider.entites import ProviderRequest
from astrbot.core.provider.register import llm_tools
from astrbot.core.tools.computer_tools import (
CuaKeyboardTypeTool,
CuaMouseClickTool,
CuaScreenshotTool,
ExecuteShellTool,
FileDownloadTool,
FileEditTool,
Expand All @@ -43,15 +41,27 @@
GrepTool,
LocalPythonTool,
PythonTool,
SandboxLifecycleTool,
SandboxOperationTool,
SandboxQueryTool,
)
from astrbot.core.tools.message_tools import SendMessageToUserTool
from astrbot.core.tools.registry import get_builtin_tool_config_rule
from astrbot.core.utils.astrbot_path import get_astrbot_temp_path
from astrbot.core.utils.history_saver import persist_agent_history
from astrbot.core.utils.image_ref_utils import is_supported_image_ref
from astrbot.core.utils.string_utils import normalize_and_dedupe_strings


class FunctionToolExecutor(BaseFunctionToolExecutor[AstrAgentContext]):
_runtime_computer_tools_cache: dict[
tuple[int, str, str], dict[str, FunctionTool]
] = {}

@classmethod
def clear_runtime_computer_tools_cache(cls, provider_id: str | None = None) -> None:
cls._runtime_computer_tools_cache.clear()

@classmethod
def _collect_image_urls_from_args(cls, image_urls_raw: T.Any) -> list[str]:
if image_urls_raw is None:
Expand Down Expand Up @@ -192,8 +202,14 @@ def _get_runtime_computer_tools(
booter: str | None = None,
) -> dict[str, FunctionTool]:
booter = "" if booter is None else str(booter).lower()
cache_key = (id(tool_mgr), runtime, booter)
if cache_key in cls._runtime_computer_tools_cache:
return cls._runtime_computer_tools_cache[cache_key]
if runtime == "sandbox":
shell_tool = tool_mgr.get_builtin_tool(ExecuteShellTool)
sandbox_query_tool = tool_mgr.get_builtin_tool(SandboxQueryTool)
sandbox_lifecycle_tool = tool_mgr.get_builtin_tool(SandboxLifecycleTool)
sandbox_operation_tool = tool_mgr.get_builtin_tool(SandboxOperationTool)
python_tool = tool_mgr.get_builtin_tool(PythonTool)
upload_tool = tool_mgr.get_builtin_tool(FileUploadTool)
download_tool = tool_mgr.get_builtin_tool(FileDownloadTool)
Expand All @@ -203,6 +219,9 @@ def _get_runtime_computer_tools(
grep_tool = tool_mgr.get_builtin_tool(GrepTool)
tools = {
shell_tool.name: shell_tool,
sandbox_query_tool.name: sandbox_query_tool,
sandbox_lifecycle_tool.name: sandbox_lifecycle_tool,
sandbox_operation_tool.name: sandbox_operation_tool,
python_tool.name: python_tool,
upload_tool.name: upload_tool,
download_tool.name: download_tool,
Expand All @@ -211,17 +230,7 @@ def _get_runtime_computer_tools(
edit_tool.name: edit_tool,
grep_tool.name: grep_tool,
}
if booter == "cua":
screenshot_tool = tool_mgr.get_builtin_tool(CuaScreenshotTool)
mouse_click_tool = tool_mgr.get_builtin_tool(CuaMouseClickTool)
keyboard_type_tool = tool_mgr.get_builtin_tool(CuaKeyboardTypeTool)
tools.update(
{
screenshot_tool.name: screenshot_tool,
mouse_click_tool.name: mouse_click_tool,
keyboard_type_tool.name: keyboard_type_tool,
}
)
cls._runtime_computer_tools_cache[cache_key] = tools
return tools
if runtime == "local":
shell_tool = tool_mgr.get_builtin_tool(ExecuteShellTool)
Expand All @@ -230,16 +239,37 @@ def _get_runtime_computer_tools(
write_tool = tool_mgr.get_builtin_tool(FileWriteTool)
edit_tool = tool_mgr.get_builtin_tool(FileEditTool)
grep_tool = tool_mgr.get_builtin_tool(GrepTool)
return {
tools = {
shell_tool.name: shell_tool,
python_tool.name: python_tool,
read_tool.name: read_tool,
write_tool.name: write_tool,
edit_tool.name: edit_tool,
grep_tool.name: grep_tool,
}
cls._runtime_computer_tools_cache[cache_key] = tools
return tools
return {}

@staticmethod
def _tool_available_for_runtime_config(tool: FunctionTool, runtime: str) -> bool:
if not tool_available_in_runtime(tool, runtime):
return False
rule = get_builtin_tool_config_rule(tool.name)
if rule is None:
return True
conditions = rule.evaluate(
{"provider_settings": {"computer_use_runtime": runtime}}
)
runtime_conditions = [
condition
for condition in conditions
if str(condition.get("key")) == "provider_settings.computer_use_runtime"
]
if not runtime_conditions:
return True
return all(bool(condition.get("matched")) for condition in runtime_conditions)

@classmethod
def _build_handoff_toolset(
cls,
Expand All @@ -259,17 +289,18 @@ def _build_handoff_toolset(
runtime_computer_tools = cls._get_runtime_computer_tools(
runtime,
tool_mgr,
provider_settings.get("sandbox", {}).get("booter"),
)

# Keep persona semantics aligned with the main agent: tools=None means
# "all tools", including runtime computer-use tools.
if tools is None:
toolset = ToolSet()
for registered_tool in llm_tools.func_list:
for registered_tool in getattr(tool_mgr, "func_list", llm_tools.func_list):
if isinstance(registered_tool, HandoffTool):
continue
if registered_tool.active:
if registered_tool.active and cls._tool_available_for_runtime_config(
registered_tool, runtime
):
toolset.add_tool(registered_tool)
for runtime_tool in runtime_computer_tools.values():
toolset.add_tool(runtime_tool)
Expand All @@ -281,14 +312,20 @@ def _build_handoff_toolset(
toolset = ToolSet()
for tool_name_or_obj in tools:
if isinstance(tool_name_or_obj, str):
registered_tool = llm_tools.get_func(tool_name_or_obj)
if registered_tool and registered_tool.active:
registered_tool = tool_mgr.get_func(tool_name_or_obj)
if (
registered_tool
and registered_tool.active
and cls._tool_available_for_runtime_config(registered_tool, runtime)
):
toolset.add_tool(registered_tool)
continue
runtime_tool = runtime_computer_tools.get(tool_name_or_obj)
if runtime_tool:
toolset.add_tool(runtime_tool)
elif isinstance(tool_name_or_obj, FunctionTool):
elif isinstance(
tool_name_or_obj, FunctionTool
) and cls._tool_available_for_runtime_config(tool_name_or_obj, runtime):
toolset.add_tool(tool_name_or_obj)
return None if toolset.empty() else toolset

Expand Down Expand Up @@ -538,11 +575,16 @@ async def _wake_main_agent_for_background_result(
message_type=session.message_type,
)
cron_event.role = event.role
session_config = ctx.get_config(umo=event.unified_msg_origin)
provider_settings = session_config.get("provider_settings", {})
config = MainAgentBuildConfig(
tool_call_timeout=run_context.tool_call_timeout,
streaming_response=ctx.get_config()
.get("provider_settings", {})
.get("stream", False),
streaming_response=provider_settings.get("stream", False),
computer_use_runtime=str(
provider_settings.get("computer_use_runtime", "local")
),
sandbox_cfg=provider_settings.get("sandbox", {}),
provider_settings=provider_settings,
)

req = ProviderRequest()
Expand Down
Loading
Loading