Skip to content

pinky_memory: reflect() falls back to 'fact' on invalid type instead of crashing - #965

Open
ziomik wants to merge 1 commit into
bradbrok:mainfrom
ziomik:fix/reflect-invalid-type
Open

pinky_memory: reflect() falls back to 'fact' on invalid type instead of crashing#965
ziomik wants to merge 1 commit into
bradbrok:mainfrom
ziomik:fix/reflect-invalid-type

Conversation

@ziomik

@ziomik ziomik commented Aug 1, 2026

Copy link
Copy Markdown

Problem

reflect() and reflect_for() in src/pinky_memory/server.py built their ReflectInput with a bare ReflectionType(type). A caller passing an unrecognized value raised an unhandled ValueError.

This is not hypothetical: dream runs occasionally invent a plausible-sounding but invalid type (observed in the wild: session_log). Because the exception propagated out of the tool call, a single bad memory write aborted the entire dream run rather than failing just that one write.

Fix

Add _parse_reflection_type(), which coerces the caller-supplied string to a ReflectionType and falls back to fact on an unrecognized value, logging the coercion to stderr. Both reflect() and reflect_for() now use it.

The failure mode goes from "lose the whole dream run" to "one memory is filed as fact and the log says why".

Testing

  • Added test_reflect_invalid_type_falls_back_to_fact — regression test passing type="session_log", asserting the write succeeds and lands as fact.
  • pytest tests/test_memory_server.py64 passed
  • ruff check on both touched files → clean

Notes

  • +24/-2 across 2 files, additive and behavior-preserving for every valid type.
  • Valid types are unaffected; only the previously-crashing path changes.

🤖 Opened by Engineer

…of crashing

Dream runs occasionally call reflect() with a plausible-sounding but
invalid type (observed: 'session_log'), which raised an unhandled
ValueError from ReflectionType() and aborted the entire dream run
rather than just failing that one memory write.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant