Skip to content

Commit 6761dd1

Browse files
committed
fix(api): preserve read-only metadata
1 parent 39a7fe9 commit 6761dd1

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

Examples/AgentCode/Sources/AgentCode/CodingTools.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ enum CodingTools {
2121
try Tool<EmptyParameters, WorkspaceStatus, CodingContext>(
2222
name: "workspace_status",
2323
description: "Inspect the current workspace root, detected package type, and git status.",
24-
isConcurrencySafe: true
24+
isConcurrencySafe: true,
25+
isReadOnly: true
2526
) { _, context in
2627
let gitStatus = try await context.commandRunner.run(
2728
CommandInvocation(command: "git", arguments: ["status", "--short", "--branch"], timeoutSeconds: 10),
@@ -39,7 +40,8 @@ enum CodingTools {
3940
try Tool<ListFilesParameters, FileList, CodingContext>(
4041
name: "list_files",
4142
description: "List text-oriented source files in the workspace.",
42-
isConcurrencySafe: true
43+
isConcurrencySafe: true,
44+
isReadOnly: true
4345
) { params, context in
4446
let limit = try ToolLimits.bounded(params.limit, default: 250, maximum: 500)
4547
let files = try context.workspace.listFiles(limit: limit + 1)
@@ -51,7 +53,8 @@ enum CodingTools {
5153
try Tool<ReadFileParameters, FileContent, CodingContext>(
5254
name: "read_file",
5355
description: "Read one UTF-8 text file inside the workspace.",
54-
isConcurrencySafe: true
56+
isConcurrencySafe: true,
57+
isReadOnly: true
5558
) { params, context in
5659
try FileContent(path: params.path, content: context.workspace.readFile(params.path))
5760
}
@@ -61,7 +64,8 @@ enum CodingTools {
6164
try Tool<GrepParameters, SearchResults, CodingContext>(
6265
name: "grep",
6366
description: "Search workspace text files by literal text or regular expression.",
64-
isConcurrencySafe: true
67+
isConcurrencySafe: true,
68+
isReadOnly: true
6569
) { params, context in
6670
try SearchEngine().search(
6771
query: params.query,
@@ -76,7 +80,8 @@ enum CodingTools {
7680
try Tool<GlobParameters, FileList, CodingContext>(
7781
name: "glob",
7882
description: "Find workspace files matching a glob pattern such as Sources/**/*.swift.",
79-
isConcurrencySafe: true
83+
isConcurrencySafe: true,
84+
isReadOnly: true
8085
) { params, context in
8186
let limit = try ToolLimits.bounded(params.limit, default: 100, maximum: 500)
8287
let files = try context.workspace.glob(params.pattern, limit: limit + 1)
@@ -88,7 +93,8 @@ enum CodingTools {
8893
try Tool<EmptyParameters, String, CodingContext>(
8994
name: "git_diff",
9095
description: "Return the current git diff for the workspace.",
91-
isConcurrencySafe: true
96+
isConcurrencySafe: true,
97+
isReadOnly: true
9298
) { _, context in
9399
try await context.workspace.currentDiff()
94100
}

Sources/AgentRunKit/Documentation.docc/Articles/DefiningTools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let searchTool = try Tool<SearchParams, String, EmptyContext>(
125125
| Property | Default | Description |
126126
|---|---|---|
127127
| `isConcurrencySafe` | `false` | Whether the tool can safely run concurrently with other tools. ``Agent`` honors this: unsafe tools form exclusive barriers in the execution schedule. |
128-
| `isReadOnly` | `false` | Whether the tool only reads state without side effects. This is advisory metadata for callers and approval policy. |
128+
| `isReadOnly` | `false` | Whether the tool only reads state without side effects. This is advisory metadata for callers. |
129129
| `maxResultCharacters` | `nil` | Per-tool override for ``AgentConfiguration/maxToolResultCharacters``. When set, this limit governs instead of the global default. |
130130
| `strict` | `nil` | Whether the provider should enforce strict JSON Schema adherence on the tool's arguments. Preserved on first-party OpenAI Chat and Responses function tools where supported; unsupported providers reject strict schemas instead of dropping the request. |
131131

Sources/AgentRunKit/Documentation.docc/Articles/SubAgents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ When a sub-agent executes, ``SubAgentTool`` calls `descending()` to increment th
9696

9797
**Tool timeout.** `toolTimeout` overrides the parent agent's default tool timeout for this sub-agent invocation. `nil` (the default) inherits the parent's ``AgentConfiguration/toolTimeout``.
9898

99-
**Tool metadata.** `SubAgentTool` also exposes `isConcurrencySafe`, `isReadOnly`, and `maxResultCharacters`, matching `Tool`. ``Agent`` honors `isConcurrencySafe` for scheduling: sibling sub-agents default to sequential execution and must opt in to concurrent execution. `isReadOnly` is advisory metadata for callers and approval policy.
99+
**Tool metadata.** `SubAgentTool` also exposes `isConcurrencySafe`, `isReadOnly`, and `maxResultCharacters`, matching `Tool`. ``Agent`` honors `isConcurrencySafe` for scheduling: sibling sub-agents default to sequential execution and must opt in to concurrent execution. `isReadOnly` is advisory metadata for callers.
100100

101101
## Streaming Propagation
102102

0 commit comments

Comments
 (0)