Skip to content

fix(agent): use atomic_json_write for request debug dumps instead of bare write_text#30857

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-35910159
May 23, 2026
Merged

fix(agent): use atomic_json_write for request debug dumps instead of bare write_text#30857
teknium1 merged 1 commit into
mainfrom
hermes/hermes-35910159

Conversation

@teknium1

@teknium1 teknium1 commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Crash mid-write no longer corrupts the API request debug dump — the file post-mortem analysis most depends on.

Changes

  • agent/agent_runtime_helpers.py: dump_file.write_text(json.dumps(...))atomic_json_write(dump_file, dump_payload, default=str) (import was already there, unused)

Validation

Before After
Mid-write crash partial file previous file intact via temp+fsync+rename
Payload with datetime/custom objects serialized via default=str preserved via default=str forwarded through **dump_kwargs

default=str is load-bearing: body is a deepcopy of api_kwargs and routinely holds datetime / httpx Response / custom objects. Without it the inner try raises TypeError and the whole dump is silently dropped — strictly worse than the partial-write being fixed.

E2E verified: real-world payload with datetime + custom class serializes correctly, no leftover temp files.

Salvage of #30602 (@sprmn24). Cherry-picked their commit onto current main, added default=str to preserve original serialization behavior.

Infographic

atomic-debug-dumps

@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-35910159 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8999 on HEAD, 8999 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4777 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit 53cb6d3 into main May 23, 2026
25 of 26 checks passed
@teknium1 teknium1 deleted the hermes/hermes-35910159 branch May 23, 2026 09:30
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have labels May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants