LangChain math adapter can corrupt answers while removing Answer prefix

Open Beginner friendly
#1,797 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
tooling

Research direction

Start by locating LangChainMathChainCompletionFn and the existing local tests for this adapter. Verify prefixed and unprefixed responses, then add regression coverage showing that only a leading Answer: prefix and surrounding whitespace are removed while answer content remains unchanged.

Written by the indexing model from the issue text.

Description

Describe the bug

LangChainMathChainCompletionFn tries to remove LangChain's Answer: prefix with:

response = response.strip("Answer:").strip()

str.strip() does not remove an exact prefix. Its argument is treated as a set of characters to remove from both ends of the string. As a result, valid answer text can be corrupted. For example:

"Answer: ten".strip("Answer:").strip() == "t"

Even a response without the prefix such as ten can be changed to t.

Expected behavior

Remove the exact leading Answer: prefix when present, then trim surrounding whitespace. Response content that is not part of that prefix must remain unchanged.

Proposed fix

Use an exact prefix check/removal instead of str.strip("Answer:"), and add focused local regression coverage for prefixed and unprefixed answers.

Dominant language
Python
Stars
19.5k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/evals

All issues in openai/evals

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.