Describe the bug
Summary
When a tool‑calling model returns an invalid tool call, the framework raises a FormatError. The exception payload can include non‑JSON‑serializable
objects (e.g., raw response objects), which causes agent.save() to fail. As a result, the final .traj.json is never written, even though
trajectories are normally always persisted.
Observed behavior
- Invalid tool call → FormatError
- agent.save() attempts to json.dumps() the trajectory
- Serialization fails due to non‑JSON‑serializable data in the error payload
- Trajectory file is not written to disk
Expected behavior
- Trajectories should always be written, even when the model response is malformed
- Error payloads should be JSON‑safe
Impact
Losing the trajectory on malformed tool calls makes debugging and evaluation difficult, and breaks expected SWE‑bench behavior.
Fix (coming soon in a PR)
- Wrap FormatError with a JSON‑safe payload (raw assistant content/tool_calls only + minimal metadata)
- Add a to_jsonable helper and use it before json.dumps() in DefaultAgent.save() so serialization is robust
Describe the bug
Summary
When a tool‑calling model returns an invalid tool call, the framework raises a FormatError. The exception payload can include non‑JSON‑serializable
objects (e.g., raw response objects), which causes agent.save() to fail. As a result, the final .traj.json is never written, even though
trajectories are normally always persisted.
Observed behavior
Expected behavior
Impact
Losing the trajectory on malformed tool calls makes debugging and evaluation difficult, and breaks expected SWE‑bench behavior.
Fix (coming soon in a PR)