Skip to content

Commit 69df88d

Browse files
committed
Apply native tool visibility to the calling session only
1 parent 402f310 commit 69df88d

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎runtime/flybot-image/native-ds-bot-overlay.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const patch = fileURLToPath(new URL('./native-ds-bot.patch', import.meta.url))
1111
const files = {
1212
'src/host/tools.js': [
1313
'a5c743b7c75c96498775808f029a5f15c7e08dbe6eaf33089d29b3c2a9ffb382',
14-
'1826917126e67e426becdcb15a4fe4be08129f29a7b29ef34ff637b9b9cb46df',
14+
'852dafff886dd8625d98152afe85432b8a22648d3627df5b61eddba4cea8c510',
1515
],
1616
'src/host/roster.js': [
1717
'20461d2d4aeae6ca373e3431a5802317d1130468e1940d22032189134429f984',

‎runtime/flybot-image/native-ds-bot.patch‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,24 @@ diff --git a/src/host/tools.js b/src/host/tools.js
20952095
const admin = args.admin ? rt.findBot(args.admin) : rt.botOf(self)
20962096
if (admin === undefined) return `No Bot named ${args.admin}. Team: ${teamNames()}`
20972097
const members = [...new Set([self, ...bots.map(bot => bot.id), admin.id])]
2098+
@@ -1189,12 +1204,16 @@
2099+
const filterBotAssembly = (agent, held) => {
2100+
if (held.filtered === true || typeof agent.ctx?.on !== 'function') return
2101+
const filterTools = agent.ctx.on('llm/stream', function filterBuiltinTools(options, next) {
2102+
+ // The LLM service waterfall is shared. A specialist's restrictions must
2103+
+ // never drop tools from the Chief's concurrent or following model call.
2104+
+ if (options.sessionId !== agent.session?.id) return next()
2105+
const hidden = rt.hiddenBuiltinTools(agent.session?.id)
2106+
if (!options.tools?.some(tool => hidden.has(tool.name))) return next()
2107+
return agent.ctx.llm.stream({ ...options, tools: options.tools.filter(tool => !hidden.has(tool.name)) })
2108+
})
2109+
if (typeof filterTools === 'function') held.disposers.push(filterTools)
2110+
- const dispose = agent.ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
2111+
+ const dispose = agent.ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
2112+
+ if (context?.agent?.session?.id !== agent.session?.id) return next()
2113+
const assembled = await next()
2114+
const hidden = new Set([...HIDDEN_TOOLS, ...rt.hiddenBuiltinTools(agent.session?.id)])
2115+
// DSH 0.2.2 adds the tool list after this waterfall (#814), so only an
20982116
diff --git a/src/host/roster.js b/src/host/roster.js
20992117
--- a/src/host/roster.js
21002118
+++ b/src/host/roster.js

‎runtime/flybot-image/test/container-gateway-isolation.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,17 @@
7575
const results = messages.slice(request + 1).filter(message => message.role === 'tool')
7676
if (results.length >= steps.length) return { text: 'CI-TEAM-CREATED' }
7777
const [name, args] = steps[results.length]
78-
const available = new Set((body.tools ?? []).map(tool => tool.function?.name))
78+
const available = new Set((body.tools ?? []).map(tool => tool.function?.name).filter(Boolean))
7979
if (available.has(name)) return { call: { name, arguments: JSON.stringify(args) }, step: results.length }
8080
if (available.has('run_code')) {
8181
return { call: { name: 'run_code', arguments: JSON.stringify({
8282
description: 'Create the fixture team',
8383
code: `return await tools.${name}(${JSON.stringify(args)})`,
8484
}) }, step: results.length }
8585
}
86-
return { text: 'CI-TEAM-TOOL-MISSING: ' + name }
86+
const guidance = messages.some(message => message.role === 'system' &&
87+
JSON.stringify(message.content).includes('## FlyBot personal workspace'))
88+
return { text: `CI-TEAM-TOOL-MISSING: ${name} (guide=${guidance}, tools=${[...available].sort().join(',')})` }
8789
}
8890
8991
require('node:http').createServer((req, res) => {
@@ -177,8 +179,10 @@ def start_bot_social(tmp, network, subnet, run, started):
177179
host, app = f'ot-gw-{run}-social', f'ot-gw-{run}-social-app'
178180
origin = f'https://{host}'
179181
ca, key, cert = make_tls(tmp, host)
180-
image = 'flybot-workspace-bot-social:ci-gateway'
181-
docker('build', '-q', '-t', image, str(ROOT / 'services' / 'bot-social'), timeout=900)
182+
image = os.environ.get('FLYBOT_WORKSPACE_GATEWAY_BOT_SOCIAL_IMAGE')
183+
if not image:
184+
image = 'flybot-workspace-bot-social:ci-gateway'
185+
docker('build', '-q', '-t', image, str(ROOT / 'services' / 'bot-social'), timeout=900)
182186
docker('run', '--detach', '--name', app, '--network', network, '--tmpfs', '/data',
183187
'-e', f'PUBLIC_BASE_URL={origin}', '-e', f'TRUST_PROXY={subnet}', image)
184188
started.append(app)

0 commit comments

Comments
 (0)