Skip to content

Commit 450b184

Browse files
committed
Fix up directory-lister to have more concise output
1 parent ab65f53 commit 450b184

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.agents/file-explorer/directory-lister.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { publisher } from '../constants'
22

33
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
import { JSONObject, JSONValue } from 'types/util-types'
45

56
interface ListDirectoryQuery {
67
path: string
@@ -31,23 +32,41 @@ const directoryLister: SecretAgentDefinition = {
3132
'Mechanically lists multiple directories and returns their contents',
3233
model: 'anthropic/claude-sonnet-4.5',
3334
publisher,
34-
outputMode: 'all_messages',
3535
includeMessageHistory: false,
36-
toolNames: ['list_directory'],
36+
outputMode: 'structured_output',
37+
toolNames: ['list_directory', 'set_output'],
3738
spawnableAgents: [],
3839
inputSchema: {
3940
params: paramsSchema,
4041
},
4142
handleSteps: function* ({ params }) {
4243
const directories: ListDirectoryQuery[] = params?.directories ?? []
4344

45+
const toolResults: JSONValue[] = []
4446
for (const directory of directories) {
45-
yield {
47+
const { toolResult } = yield {
4648
toolName: 'list_directory',
4749
input: {
4850
path: directory.path,
4951
},
5052
}
53+
if (toolResult) {
54+
toolResults.push(
55+
...toolResult
56+
.filter((result) => result.type === 'json')
57+
.map((result) => ({
58+
path: directory.path,
59+
...(result.value as JSONObject),
60+
})),
61+
)
62+
}
63+
}
64+
65+
yield {
66+
toolName: 'set_output',
67+
input: {
68+
results: toolResults,
69+
},
5170
}
5271
},
5372
}

0 commit comments

Comments
 (0)