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 versions.

  • LangChainProvider (src/LangChainProvider.ts):
    • Structured Output: Add invokeStructuredModel(messages, responseStructure) using withStructuredOutput(...), returning StructuredResponse with serialized raw response and zeroed usage metrics.
    • Error Handling: Wrap invokeModel and invokeStructuredModel in try/catch to return success=false on failures and emit warnings; maintain assistant message shape on errors.
    • Types: Import StructuredResponse.
  • Tests (__tests__/LangChainProvider.test.ts):
    • Add tests for invokeModel error case and for invokeStructuredModel success/error paths, including metrics and logging assertions.
  • Dependencies (package.json):
    • Align @launchdarkly/server-sdk-ai dev/peer versions to ^0.12.0.

Written by Cursor Bugbot for commit 4c38dcc. 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

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