diff --git a/packages/ai/test/tool-argument-coercion.test.ts b/packages/ai/test/tool-argument-coercion.test.ts index 41edb9c69..679775d0f 100644 --- a/packages/ai/test/tool-argument-coercion.test.ts +++ b/packages/ai/test/tool-argument-coercion.test.ts @@ -179,6 +179,38 @@ describe("Tool argument coercion", () => { expect(result.edits).toEqual([{ target: "13#cf", new_content: "..." }]); }); + it("coerces quoted edit arrays before stripping optional null fields", () => { + const textSchema = Type.Union([Type.Array(Type.String()), Type.String()]); + const tool: Tool = { + name: "atom-like-edit", + description: "", + parameters: Type.Object({ + path: Type.String(), + edits: Type.Array( + Type.Object({ + loc: Type.String(), + set: Type.Optional(textSchema), + pre: Type.Optional(textSchema), + post: Type.Optional(textSchema), + sub: Type.Optional(Type.Tuple([Type.String(), Type.String()])), + }), + ), + }), + }; + const toolCall: ToolCall = { + type: "toolCall", + id: "call-atom-like-edit", + name: "atom-like-edit", + arguments: { + path: "orcid.ts", + edits: '[{"loc":"276ka-282vu","pre":null,"set":["line"],"post":null,"sub":null}]', + }, + }; + + const result = validateToolArguments(tool, toolCall) as { edits: Array> }; + expect(result.edits).toEqual([{ loc: "276ka-282vu", set: ["line"] }]); + }); + it("coerces array strings with trailing wrapper braces from malformed nested JSON", () => { const tool: Tool = { name: "t16", diff --git a/packages/coding-agent/src/modes/components/footer.ts b/packages/coding-agent/src/modes/components/footer.ts index 7b83b05aa..1588afdd9 100644 --- a/packages/coding-agent/src/modes/components/footer.ts +++ b/packages/coding-agent/src/modes/components/footer.ts @@ -56,22 +56,27 @@ export class FooterComponent implements Component { this.#gitWatcher = null; } - git.head.resolve(getProjectDir()).then(head => { - if (!head) { - return; - } + void git.head + .resolve(getProjectDir()) + .then(head => { + if (!head) { + return; + } - try { - this.#gitWatcher = fs.watch(head.headPath, () => { - this.#cachedBranch = undefined; // Invalidate cache - if (this.#onBranchChange) { - this.#onBranchChange(); - } - }); - } catch { - // Silently fail if we can't watch - } - }); + try { + this.#gitWatcher = fs.watch(head.headPath, () => { + this.#cachedBranch = undefined; // Invalidate cache + if (this.#onBranchChange) { + this.#onBranchChange(); + } + }); + } catch { + // Silently fail if we can't watch + } + }) + .catch(() => { + this.#cachedBranch = null; + }); } /** diff --git a/packages/coding-agent/src/tools/report-tool-issue.ts b/packages/coding-agent/src/tools/report-tool-issue.ts index 4329b42c3..1d2ddcaa6 100644 --- a/packages/coding-agent/src/tools/report-tool-issue.ts +++ b/packages/coding-agent/src/tools/report-tool-issue.ts @@ -57,6 +57,7 @@ export function createReportToolIssueTool(session: ToolSession): AgentTool { return { name: "report_tool_issue", label: "Report Tool Issue", + strict: false, description: "Report unexpected tool behavior for automated QA tracking.", parameters: ReportToolIssueParams, async execute(_toolCallId, rawParams) {