Skip to content

feat: Update LangChain runners to implement Runner protocol returning RunnerResult#150

Open
jsonbailey wants to merge 1 commit intojb/aic-2388/openai-runner-protocolfrom
jb/aic-2388/langchain-runner-protocol
Open

feat: Update LangChain runners to implement Runner protocol returning RunnerResult#150
jsonbailey wants to merge 1 commit intojb/aic-2388/openai-runner-protocolfrom
jb/aic-2388/langchain-runner-protocol

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented Apr 28, 2026

Summary

  • `LangChainModelRunner` and `LangChainAgentRunner` now formally inherit from the `Runner` protocol class.
  • `LangChainModelRunner.run()` implements the unified `Runner` protocol; returns `RunnerResult` with `content`, `metrics`, `raw`, and `parsed` fields. Structured output is supported via the `output_type` parameter.
  • `LangChainAgentRunner.run()` updated to return `RunnerResult`; populates `tool_calls` in `LDAIMetrics` from observed tool call names in the message response.
  • Legacy `invoke_model()` and `invoke_structured_model()` removed — the deprecated type definitions (`ModelRunner`, `AgentRunner`, `ModelResponse`, etc.) are kept in `server-ai` for provider CI compatibility until a cleanup PR removes them.

Stacking

Stacked on top of `jb/aic-2388/openai-runner-protocol` (PR #149).

Test plan

  • `make test-langchain` — all LangChain provider tests pass
  • `make test` — all tests across server-ai, langchain, and openai packages pass

🤖 Generated with Claude Code

@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from f1845b4 to 94f09ee Compare April 29, 2026 13:14
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 37bad31 to b708885 Compare April 29, 2026 13:14
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 94f09ee to 8463109 Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from b708885 to c553fbd Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 8463109 to eacddee Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from c553fbd to 5df809b Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from eacddee to 842e4e6 Compare April 29, 2026 13:46
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 5df809b to c6e35a4 Compare April 29, 2026 13:48
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 842e4e6 to 4c95357 Compare April 29, 2026 13:56
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from c6e35a4 to 08dfcb7 Compare April 29, 2026 13:56
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 4c95357 to 3f6882c Compare April 29, 2026 14:38
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 08dfcb7 to ca37e74 Compare April 29, 2026 14:38
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 3f6882c to efeea93 Compare April 29, 2026 16:31
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from ca37e74 to 9c0003c Compare April 29, 2026 16:31
@jsonbailey jsonbailey marked this pull request as ready for review April 29, 2026 16:36
@jsonbailey jsonbailey requested a review from a team as a code owner April 29, 2026 16:36
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from efeea93 to 330acf1 Compare April 29, 2026 16:49
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 9c0003c to 1aa1069 Compare April 29, 2026 16:49
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1aa1069. Configure here.

content='',
metrics=LDAIMetrics(success=False, usage=None),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing deprecated adapter methods breaks Judge evaluations

High Severity

The PR description states that legacy invoke_model() and invoke_structured_model() are "retained as deprecated adapters that delegate to run() for backward compatibility," but both methods were completely removed from LangChainModelRunner. The Judge class at packages/sdk/server-ai/src/ldai/judge/__init__.py:79 directly calls self._model_runner.invoke_structured_model(...), and the deprecated ManagedModel.invoke() at packages/sdk/server-ai/src/ldai/managed_model.py:121 calls self._model_runner.invoke_model(...). When a LangChainModelRunner is used as the judge's model runner (which happens via RunnerFactory.create_model()), both paths will crash with AttributeError at runtime.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1aa1069. Configure here.

@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 330acf1 to cd983aa Compare April 29, 2026 17:13
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 1aa1069 to f811cf8 Compare April 29, 2026 17:13
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from cd983aa to 184be64 Compare April 29, 2026 17:14
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from f811cf8 to e56ea8f Compare April 29, 2026 17:15
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 184be64 to 4138d3c Compare April 29, 2026 17:18
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from e56ea8f to 4e0b78d Compare April 29, 2026 17:18
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 4138d3c to 7df7854 Compare April 29, 2026 17:37
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 4e0b78d to c1c2c8c Compare April 29, 2026 17:37
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 7df7854 to 3556ba4 Compare April 29, 2026 17:58
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from c1c2c8c to a233c2f Compare April 29, 2026 17:59
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from 3556ba4 to b5f15b7 Compare April 29, 2026 21:07
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from a233c2f to a770b1f Compare April 29, 2026 21:07
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from b5f15b7 to dc86b07 Compare April 29, 2026 21:13
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from a770b1f to 069c0ee Compare April 29, 2026 21:13
@jsonbailey jsonbailey force-pushed the jb/aic-2388/openai-runner-protocol branch from dc86b07 to 2ba8406 Compare April 29, 2026 21:56
… RunnerResult

- LangChainModelRunner.run() implements the unified Runner protocol; returns RunnerResult
  with content, metrics (LDAIMetrics), raw, and parsed fields. Structured output is
  supported via the output_type parameter.
- LangChainAgentRunner.run() updated to return RunnerResult; populates tool_calls in
  LDAIMetrics from observed tool_calls in message responses.
- Legacy invoke_model() and invoke_structured_model() retained as deprecated adapters
  that delegate to run() and wrap results into ModelResponse / StructuredResponse for
  backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2388/langchain-runner-protocol branch from 069c0ee to 1c0255f Compare April 29, 2026 21:56
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.

1 participant