Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rdagent/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def __reduce__(self) -> NoReturn:


def parse_json(response: str) -> Any:
import re

# Some LLM providers (e.g. Volcengine) return Python-style booleans
# (True/False) instead of JSON-standard (true/false). Normalize them
# before parsing to avoid JSONDecodeError.
response = re.sub(r"\bTrue\b", "true", response)
response = re.sub(r"\bFalse\b", "false", response)
response = re.sub(r"\bNone\b", "null", response)
try:
return json.loads(response)
except json.decoder.JSONDecodeError:
Expand Down
3 changes: 3 additions & 0 deletions rdagent/log/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ def get_msgs_until(end_func: Callable[[Message], bool] = lambda _: True):
state.hypotheses[state.lround] = msg.content
elif "evolving code" in tags:
msg.content = [i for i in msg.content if i]
# Also store under the short key so downstream consumers
# that read state.msgs[round]["evolving code"] can find it.
state.msgs[state.lround]["evolving code"].append(msg)
elif "evolving feedback" in tags:
total_len = len(msg.content)
none_num = total_len - len(msg.content)
Expand Down
7 changes: 6 additions & 1 deletion rdagent/log/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ def extract_evoid(tag: str) -> str | None:
def extract_json(log_content: str) -> dict | None:
match = re.search(r"\{.*\}", log_content, re.DOTALL)
if match:
return cast(dict, json.loads(match.group(0)))
raw = match.group(0)
# Normalize Python-style booleans/null that some LLM providers return
raw = re.sub(r"\bTrue\b", "true", raw)
raw = re.sub(r"\bFalse\b", "false", raw)
raw = re.sub(r"\bNone\b", "null", raw)
return cast(dict, json.loads(raw))
return None


Expand Down
Loading