Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/core/src/core/openaiContentGenerator/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5841,8 +5841,11 @@ describe('ContentGenerationPipeline', () => {
expect(err).toBeInstanceOf(StreamInactivityTimeoutError);
expect((err as Error).message).toBe(
'No stream activity for 1000ms after 0 chunks ' +
'(stream lifetime: 1000ms). Set QWEN_STREAM_IDLE_TIMEOUT_MS ' +
'to increase this window (or 0 to disable it).',
'(stream lifetime: 1000ms). Increase ' +
'model.generationConfig.streamIdleTimeoutMs or the matching ' +
'modelProviders[providerId][].generationConfig.streamIdleTimeoutMs; ' +
'when neither is set, use QWEN_STREAM_IDLE_TIMEOUT_MS. ' +
'Set the active value to 0 to disable it.',
);
expect(err).toMatchObject({ code: 'ETIMEDOUT' });
expect((err as StreamInactivityTimeoutError).chunksReceived).toBe(0);
Expand All @@ -5851,7 +5854,7 @@ describe('ContentGenerationPipeline', () => {
expect(mockErrorHandler.handle).not.toHaveBeenCalled();
});

it('includes the idle detail and env override hint in timeout errors', async () => {
it('includes settings and environment override hints in timeout errors', async () => {
const gated = gatedStream(); // never push/end → silent
(mockClient.chat.completions.create as Mock).mockResolvedValue(
gated.stream,
Expand All @@ -5871,6 +5874,10 @@ describe('ContentGenerationPipeline', () => {
expect(err).toBeInstanceOf(StreamInactivityTimeoutError);
const message = (err as Error).message;
expect(message).toContain('No stream activity for 1000ms after 0 chunks');
expect(message).toContain('model.generationConfig.streamIdleTimeoutMs');
expect(message).toContain(
'modelProviders[providerId][].generationConfig.streamIdleTimeoutMs',
);
expect(message).toContain('QWEN_STREAM_IDLE_TIMEOUT_MS');
});

Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/core/openaiContentGenerator/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ export class StreamInactivityTimeoutError extends Error {
) {
super(
`No stream activity for ${idleMs}ms after ${chunksReceived} chunks ` +
`(stream lifetime: ${streamLifetimeMs}ms). Set ` +
`${QWEN_STREAM_IDLE_TIMEOUT_MS_ENV} to increase this window ` +
`(or 0 to disable it).`,
`(stream lifetime: ${streamLifetimeMs}ms). Increase ` +
`model.generationConfig.streamIdleTimeoutMs or the matching ` +
`modelProviders[providerId][].generationConfig.streamIdleTimeoutMs; ` +
Comment thread
yu-xin-c marked this conversation as resolved.
Resolved
`when neither is set, use ${QWEN_STREAM_IDLE_TIMEOUT_MS_ENV}. ` +
`Set the active value to 0 to disable it.`,
);
this.name = 'StreamInactivityTimeoutError';
}
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/models/content-generator-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ describe('buildAgentContentGeneratorConfig', () => {
expect(result.extra_body).toBeUndefined();
});

it('should preserve a zero stream idle timeout from the registry', () => {
const config = createMockConfig(parentConfig, {
...resolvedModel,
generationConfig: {
...resolvedModel.generationConfig,
streamIdleTimeoutMs: 0,
},
});

const result = buildAgentContentGeneratorConfig(
config,
'registry-model-id',
{ authType: 'anthropic' },
);

expect(result.streamIdleTimeoutMs).toBe(0);
});

it('should prefer explicit auth overrides over registry values', () => {
const config = createMockConfig(parentConfig, resolvedModel);

Expand Down
Loading