Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix newline whitespace escaping when parsing LLM output

Tomas Valentaa1a33495b4ce
diff --git a/api-service/codegen/agent/parsing.py b/api-service/codegen/agent/parsing.py
index 4d47770c3..1945a3e25 100644
--- a/api-service/codegen/agent/parsing.py
+++ b/api-service/codegen/agent/parsing.py
@@ -5,7 +5,6 @@ from typing import TypedDict
from typing import Literal
from lxml import etree
-
escape_table = str.maketrans({
"<": "&lt;",
">": "&gt;",
@@ -39,7 +38,7 @@ def merge_logs(log: TypedDict, other: TypedDict):
action_tag_open = "<action(\\s+tool=\".+?\")?\\s*/?>?"
action_tag_close = "</\\s*action\\s*>?"
-action_tag_split_pattern = re.compile(f"({action_tag_open}.*?{action_tag_close})|(.+)")
+action_tag_split_pattern = re.compile(f"({action_tag_open})|({action_tag_close})|(.+?)")
action_tag_check_pattern = re.compile(f"{action_tag_open}|{action_tag_close}")
def parse_thoughts_and_actions(text: str):