mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 16:34:31 -07:00
Give explicit instructions for failure text in json-output.test.ts (#11029)
This commit is contained in:
@@ -87,7 +87,8 @@ describe('JSON output', () => {
|
|||||||
|
|
||||||
it('should not exit on tool errors and allow model to self-correct in JSON mode', async () => {
|
it('should not exit on tool errors and allow model to self-correct in JSON mode', async () => {
|
||||||
const result = await rig.run(
|
const result = await rig.run(
|
||||||
'Read the contents of /path/to/nonexistent/file.txt and tell me what it says',
|
`Read the contents of ${rig.testDir}/path/to/nonexistent/file.txt and tell me what it says. ` +
|
||||||
|
'On error, respond to the user with exactly the text "File not found".',
|
||||||
'--output-format',
|
'--output-format',
|
||||||
'json',
|
'json',
|
||||||
);
|
);
|
||||||
@@ -99,14 +100,22 @@ describe('JSON output', () => {
|
|||||||
expect(parsed).toHaveProperty('response');
|
expect(parsed).toHaveProperty('response');
|
||||||
expect(typeof parsed.response).toBe('string');
|
expect(typeof parsed.response).toBe('string');
|
||||||
|
|
||||||
// The model should acknowledge the error in its response
|
// The model should acknowledge the error in its response with exactly the
|
||||||
|
// text "File not found" based on the instruction above, but we also match
|
||||||
|
// some other forms. If you get flakes for this test please file an issue to
|
||||||
|
// come up with a more robust solution.
|
||||||
expect(parsed.response.toLowerCase()).toMatch(
|
expect(parsed.response.toLowerCase()).toMatch(
|
||||||
/cannot|does not exist|doesn't exist|not found|unable to|error|couldn't/,
|
/cannot|does not exist|doesn't exist|not found|unable to|error|couldn't/,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Stats should be present, indicating the session completed normally
|
// Stats should be present, indicating the session completed normally.
|
||||||
expect(parsed).toHaveProperty('stats');
|
expect(parsed).toHaveProperty('stats');
|
||||||
|
|
||||||
|
// Should see one failed tool call in the stats.
|
||||||
expect(parsed.stats).toHaveProperty('tools');
|
expect(parsed.stats).toHaveProperty('tools');
|
||||||
|
expect(parsed.stats.tools.totalCalls).toBe(1);
|
||||||
|
expect(parsed.stats.tools.totalFail).toBe(1);
|
||||||
|
expect(parsed.stats.tools.totalSuccess).toBe(0);
|
||||||
|
|
||||||
// Should NOT have an error field at the top level
|
// Should NOT have an error field at the top level
|
||||||
expect(parsed.error).toBeUndefined();
|
expect(parsed.error).toBeUndefined();
|
||||||
|
|||||||
Reference in New Issue
Block a user