Switch to a more robust code detection regex #19

Open
opened 2026-02-16 07:16:31 -05:00 by yindo · 0 comments
Owner

Originally created by @yoavkantor on GitHub (Aug 31, 2025).

Mistral-large generates code blocks that are not detected by the regex.
Although they have <code> or python <code> structure.
Maybe some requirements can be relaxed.

Suggested more relaxed regex: r'(?:\w+)?\n?(.*?)\n?'

Example for a non-detected code block:

# Step 1: Use the Milvus retriever tool to find information about the song featured in the movie Hamrahi
results = _milvus_retriever_tool_dataset(query="song featured in the movie Hamrahi")

# Step 2: Print the results to see if we can find the name of the song
print(results)
Originally created by @yoavkantor on GitHub (Aug 31, 2025). Mistral-large generates code blocks that are not detected by the regex. Although they have ``` <code> ``` or ```python <code> ``` structure. Maybe some requirements can be relaxed. Suggested more relaxed regex: r'```(?:\w+)?\n?(.*?)\n?```' Example for a non-detected code block: ``` # Step 1: Use the Milvus retriever tool to find information about the song featured in the movie Hamrahi results = _milvus_retriever_tool_dataset(query="song featured in the movie Hamrahi") # Step 2: Print the results to see if we can find the name of the song print(results) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph-codeact#19