Skip to content

Commit 576dda2

Browse files
committed
[AI] fix(tool-call-repair): address lint errors in test files
- grammar.test.ts: remove unused functionOpen, rename params_ to p - payload.test.ts: replace result! assertions with local const blocks = result! Related to: #98984
1 parent 41fca16 commit 576dda2

2 files changed

Lines changed: 31 additions & 24 deletions

File tree

‎packages/tool-call-repair/src/grammar.test.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ describe("indexOfAsciiMarkerIgnoreCase", () => {
404404
});
405405

406406
describe("findXmlishToolCallEnd", () => {
407-
const functionOpen = "<function=get_weather>";
408407
const parameterBlock = '<parameter=location>{"city":"NYC"}</parameter>';
409408
const functionClose = "</function>";
410409

@@ -414,9 +413,9 @@ describe("findXmlishToolCallEnd", () => {
414413
closeTag?: string;
415414
}): string {
416415
const fn = params?.functionName ?? "get_weather";
417-
const params_ = params?.parameters ?? parameterBlock;
416+
const p = params?.parameters ?? parameterBlock;
418417
const close = params?.closeTag ?? functionClose;
419-
return `<function=${fn}>${params_}${close}`;
418+
return `<function=${fn}>${p}${close}`;
420419
}
421420

422421
it("finds end of XML-ish tool call", () => {

‎packages/tool-call-repair/src/payload.test.ts‎

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,62 @@ describe("parseStandalonePlainTextToolCallBlocks", () => {
1010
'[get_weather]\n{"city":"NYC"}\n[END_TOOL_REQUEST]',
1111
);
1212
expect(result).not.toBeNull();
13-
expect(result).toHaveLength(1);
14-
expect(result![0]!.name).toBe("get_weather");
15-
expect(result![0]!.arguments).toEqual({ city: "NYC" });
13+
const blocks = result!;
14+
expect(blocks).toHaveLength(1);
15+
expect(blocks[0]!.name).toBe("get_weather");
16+
expect(blocks[0]!.arguments).toEqual({ city: "NYC" });
1617
});
1718

1819
it("parses multiple bracket-style tool calls", () => {
1920
const result = parseStandalonePlainTextToolCallBlocks(
2021
'[get_weather]\n{"city":"NYC"}\n[END_TOOL_REQUEST]\n[search]\n{"q":"hello"}\n[/search]',
2122
);
2223
expect(result).not.toBeNull();
23-
expect(result).toHaveLength(2);
24-
expect(result![0]!.name).toBe("get_weather");
25-
expect(result![1]!.name).toBe("search");
24+
const blocks = result!;
25+
expect(blocks).toHaveLength(2);
26+
expect(blocks[0]!.name).toBe("get_weather");
27+
expect(blocks[1]!.name).toBe("search");
2628
});
2729

2830
it("parses tool: prefix bracket opening (no newline or closing marker required)", () => {
2931
const result = parseStandalonePlainTextToolCallBlocks(
3032
'[tool:get_weather]{"city":"NYC"}',
3133
);
3234
expect(result).not.toBeNull();
33-
expect(result).toHaveLength(1);
34-
expect(result![0]!.name).toBe("get_weather");
35-
expect(result![0]!.arguments).toEqual({ city: "NYC" });
35+
const blocks = result!;
36+
expect(blocks).toHaveLength(1);
37+
expect(blocks[0]!.name).toBe("get_weather");
38+
expect(blocks[0]!.arguments).toEqual({ city: "NYC" });
3639
});
3740

3841
it("parses harmony-style tool call with channel marker", () => {
3942
const result = parseStandalonePlainTextToolCallBlocks(
4043
'<|channel|>commentary to=get_weather code {"city":"NYC"}<|call|>',
4144
);
4245
expect(result).not.toBeNull();
43-
expect(result).toHaveLength(1);
44-
expect(result![0]!.name).toBe("get_weather");
46+
const blocks = result!;
47+
expect(blocks).toHaveLength(1);
48+
expect(blocks[0]!.name).toBe("get_weather");
4549
});
4650

4751
it("parses harmony-style tool call without channel marker", () => {
4852
const result = parseStandalonePlainTextToolCallBlocks(
4953
'analysis to=search code {"q":"test"}<|call|>',
5054
);
5155
expect(result).not.toBeNull();
52-
expect(result).toHaveLength(1);
53-
expect(result![0]!.name).toBe("search");
56+
const blocks = result!;
57+
expect(blocks).toHaveLength(1);
58+
expect(blocks[0]!.name).toBe("search");
5459
});
5560

5661
it("parses harmony-style with optional message marker", () => {
5762
const result = parseStandalonePlainTextToolCallBlocks(
5863
'final to=summarize code <|message|> {"text":"hello"}<|call|>',
5964
);
6065
expect(result).not.toBeNull();
61-
expect(result).toHaveLength(1);
62-
expect(result![0]!.name).toBe("summarize");
66+
const blocks = result!;
67+
expect(blocks).toHaveLength(1);
68+
expect(blocks[0]!.name).toBe("summarize");
6369
});
6470

6571
it("respects allowedToolNames filter", () => {
@@ -151,9 +157,10 @@ describe("parseStandalonePlainTextToolCallBlocks", () => {
151157
'[tool:search]{"q":"hello"}[tool:weather]{"city":"NYC"}',
152158
);
153159
expect(result).not.toBeNull();
154-
expect(result).toHaveLength(2);
155-
expect(result![0]!.name).toBe("search");
156-
expect(result![1]!.name).toBe("weather");
160+
const blocks = result!;
161+
expect(blocks).toHaveLength(2);
162+
expect(blocks[0]!.name).toBe("search");
163+
expect(blocks[1]!.name).toBe("weather");
157164
});
158165

159166
it("rejects bracket style missing newline before JSON", () => {
@@ -175,9 +182,10 @@ describe("parseStandalonePlainTextToolCallBlocks", () => {
175182
const text = '[get_weather]\n{"city":"NYC"}\n[END_TOOL_REQUEST]';
176183
const result = parseStandalonePlainTextToolCallBlocks(text);
177184
expect(result).not.toBeNull();
178-
expect(result![0]!.start).toBe(0);
179-
expect(result![0]!.end).toBe(text.length);
180-
expect(result![0]!.raw).toBe(text);
185+
const blocks = result!;
186+
expect(blocks[0]!.start).toBe(0);
187+
expect(blocks[0]!.end).toBe(text.length);
188+
expect(blocks[0]!.raw).toBe(text);
181189
});
182190
});
183191

0 commit comments

Comments
 (0)