feat(ai): LangChain agent test harness — fake() AIMessage support, fake_chat_model, Agent.record()#138
Closed
bedus-creation wants to merge 1 commit into
Closed
feat(ai): LangChain agent test harness — fake() AIMessage support, fake_chat_model, Agent.record()#138bedus-creation wants to merge 1 commit into
bedus-creation wants to merge 1 commit into
Conversation
…ort, fake_chat_model, Agent.record() Add a lightweight harness for running LLM agents in tests without hitting a real model API: - fake() now accepts LangChain AIMessage values (content + tool_calls) in addition to AgentResponse and AgentSnapshot - fake_chat_model()/Agent.fake_model() build a fake chat model that replays a scripted sequence of turns, so create_agent() runs a full tool-calling loop offline (adds the bind_tools() shim GenericFakeChatModel lacks) - Agent.record() provides an explicit VCR-style record-then-replay entry point - new optional [langchain] extra; langchain imports stay lazy so the base package imports without it Tests: 11 new (record VCR + AIMessage fakes + offline create_agent loop); full suite green (1559 passed, 7 skipped).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a lightweight test harness on top of LangChain so tests can run LLM agents without hitting a real model API. Builds on the existing `ai/` module (whose `Agent.fake()` glob-stubbing + `AgentSnapshot` replay already existed) and fills in the LangChain pieces sketched in the reference prototype (`example/agents/tinker.py`).
This is the lower-risk, additive approach: the existing raw-SDK `_run` path is untouched, and all prior tests stay green.
Changes
Design notes
Tests