Keep output/error on opencode file_search items

Failed read/grep/glob tools projected only {status: failed, pattern} —
the provider's error message was unrecoverable from projections, and
successful outputs were dropped too (audit plan #12, thread 3029dc85
item prt_f15692f3). The file_search contract gains optional output and
error fields; the OpenCode adapter maps part.state.output/error by
terminal status.

App-verified with a real OpenCode agent: a successful package.json read
projects the content in output, and a read of a nonexistent file
projects status failed with error "File not found: ...".

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 committed 2026-07-12 11:51:17 +02:00
1 parent 7177ae1264
commit cf23cc1dd1
2 files changed
+12

No files matched your search

@@ -1380,6 +1380,14 @@ export function makeOpenCodeAdapterV2(options: OpenCodeAdapterV2Options): Provid
...(recordString(input, "pattern", "query", "path", "filePath") === undefined
? {}
: { pattern: recordString(input, "pattern", "query", "path", "filePath")! }),
// Keep the tool's outcome: a failed read/grep/glob previously
// projected only the pattern, leaving the provider's error
// message unrecoverable (audit plan #12).
...(output === undefined
? {}
: part.state.status === "error"
? { error: output }
: { output }),
};
} else if (projectionKind === "web_search") {
const pattern = recordString(input, "query", "url", "pattern");
@@ -827,6 +827,8 @@ export const OrchestrationV2TurnItem = Schema.Union([
type: Schema.Literal("file_search"),
pattern: Schema.optional(Schema.String),
results: Schema.optional(Schema.Array(OrchestrationV2FileSearchResult)),
output: Schema.optional(Schema.String),
error: Schema.optional(Schema.String),
}),
Schema.Struct({
...OrchestrationV2TurnItemBaseFields,
@@ -1421,6 +1423,8 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
type: Schema.Literal("file_search"),
pattern: Schema.optional(Schema.String),
results: Schema.optional(Schema.Array(OrchestrationV2FileSearchResult)),
output: Schema.optional(Schema.String),
error: Schema.optional(Schema.String),
}),
Schema.Struct({
...OrchestrationV2TurnItemJsonBaseFields,