You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Flaky test in langchain_messages.py - qualitative assertion too strict #384
assert 'Hi there!' in 'The last message you sent to me was "Hello!". How can I assist you today?'
AssertionError: assert 'Hi there!' in 'The last message you sent to me was "Hello!". How can I assist you today?'
Test Setup
# Context contains:# - System: "You are a helpful assistant"# - Human: "Hello!"# - AI: "Hi there!"# Question asked:response=m.chat(
"What was the last assistant message?",
model_options={ModelOption.SEED: 2}
).contentassert"Hi there!"inresponse# FAILS
Root Cause
Model misinterprets "last assistant message" as "last message to the assistant" and references the human's "Hello!" instead of its own "Hi there!".
Contributing factors:
Ambiguous phrasing in the question
Exact string matching inappropriate for qualitative output
Model instruction-following variability (even with seed)
response=m.chat(
"What was the last message YOU sent?",
model_options={ModelOption.SEED: 2}
).contentassertany(wordinresponse.lower() forwordin ["hi", "there"])
Option 2: Test functionality, not exact output
# Just verify context access worksassertlen(response) >0
Option 3: Improve system prompt
SystemMessage(content="You are a helpful assistant. Answer questions about the conversation literally and accurately.")
Recommendation
Option 1 - qualitative tests should never use exact string matching. The test's purpose is verifying context handling, not exact phrasing.
Additional Context
Context is correctly passed to the model (it mentions "Hello!"). Issue is instruction-following + strict assertion.
Closing as not seen in practice recently. The assertion question was tightened in a prior fix, which appears to have resolved the flakiness. The broader problem of exact-string assertions on LLM output is being tracked more systematically in #692 and #735.
Activity
psschwei commentedon May 12, 2026
@planetf1 is this still an issue?
planetf1 commentedon May 13, 2026
Closing as not seen in practice recently. The assertion question was tightened in a prior fix, which appears to have resolved the flakiness. The broader problem of exact-string assertions on LLM output is being tracked more systematically in #692 and #735.