Adding session id as part of json o/p (#14504)

This commit is contained in:
Jainam M
2025-12-04 22:36:20 +05:30
committed by GitHub
parent 84f521b1c6
commit 8b0a8f47c1
8 changed files with 126 additions and 27 deletions

View File

@@ -37,6 +37,15 @@ describe('JSON output', () => {
expect(typeof parsed.stats).toBe('object');
});
it('should return a valid JSON with a session ID', async () => {
const result = await rig.run('Hello', '--output-format', 'json');
const parsed = JSON.parse(result);
expect(parsed).toHaveProperty('session_id');
expect(typeof parsed.session_id).toBe('string');
expect(parsed.session_id).not.toBe('');
});
it('should return a JSON error for sd auth mismatch before running', async () => {
process.env['GOOGLE_GENAI_USE_GCA'] = 'true';
await rig.setup('json-output-auth-mismatch', {
@@ -87,6 +96,9 @@ describe('JSON output', () => {
"enforced authentication type is 'gemini-api-key'",
);
expect(payload.error.message).toContain("current type is 'oauth-personal'");
expect(payload).toHaveProperty('session_id');
expect(typeof payload.session_id).toBe('string');
expect(payload.session_id).not.toBe('');
});
it('should not exit on tool errors and allow model to self-correct in JSON mode', async () => {
@@ -129,5 +141,9 @@ describe('JSON output', () => {
// Should NOT have an error field at the top level
expect(parsed.error).toBeUndefined();
expect(parsed).toHaveProperty('session_id');
expect(typeof parsed.session_id).toBe('string');
expect(parsed.session_id).not.toBe('');
});
});