Skip to content

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Oct 29, 2025

Note

Adds invokeStructuredModel with structured output support and wraps invokeModel with error handling; updates tests and aligns SDK peer/dev versions.

  • LangChainProvider (src/LangChainProvider.ts)
    • Structured Output: Add invokeStructuredModel(messages, responseStructure) returning StructuredResponse with data, rawResponse, and basic metrics.
    • Error Handling: Wrap invokeModel in try/catch; on failure, return empty assistant message with success=false and log warning.
  • Tests (__tests__/LangChainProvider.test.ts)
    • Add tests for invokeModel error path.
    • Add tests for invokeStructuredModel success and failure cases.
  • Dependencies (package.json)
    • Align @launchdarkly/server-sdk-ai to ^0.12.0 in dev and peer dependencies.

Written by Cursor Bugbot for commit 24d7520. This will update automatically on new commits. Configure here.

@jsonbailey jsonbailey requested a review from a team as a code owner October 29, 2025 19:33
@jsonbailey
Copy link
Contributor Author

This PR is reliant on #969 being merged first.

@github-actions
Copy link
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 169118 bytes
Compressed size limit: 200000
Uncompressed size: 789399 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 24988 bytes
Compressed size limit: 26000
Uncompressed size: 122411 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 21721 bytes
Compressed size limit: 25000
Uncompressed size: 74698 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 17636 bytes
Compressed size limit: 20000
Uncompressed size: 90259 bytes

expect(mockLogger.error).toHaveBeenCalledWith(
'LangChain structured model invocation failed:',
error,
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Mismatched Logging Levels for Model Invocation Errors

The invokeModel and invokeStructuredModel methods in LangChainProvider.ts log caught errors using logger.warn(), but their corresponding tests expect logger.error(). This mismatch causes test failures and suggests an incorrect severity classification for these error conditions.

Additional Locations (3)

Fix in Cursor Fix in Web

metrics,
};
} catch (error) {
this.logger?.warn('LangChain structured model invocation failed:', error);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Mismatch: log level for model invocation failures should be error

The invokeModel and invokeStructuredModel methods log model invocation failures at the warn level, but their corresponding tests expect error level logging. This mismatch causes test failures and suggests error is the more appropriate log level for these critical failures.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants