5569c99b8e
Intermediate assistant messages (with tool_calls) and tool result messages are never sent to the user but remain in the model's context. This causes the model to refer to content the user never saw. Add _hidden_sig field at message creation time (context.py), then apply [HIDDEN:sig] prefix at read time (session get_history) so the model sees which messages were hidden. Storing the signature separately from content preserves Anthropic prompt caching — the same prefixed string is produced every turn. Changes: - visibility.py: add compute_signature(), refactor sign_content/verify to use it, fix Tuple -> tuple (PEP 585) - context.py: add_assistant_message() and add_tool_result() store _hidden_sig - session/manager.py: get_history() applies [HIDDEN:sig] prefix at read time - tests/test_message_visibility.py: 14 tests covering compute_signature, _hidden_sig creation, get_history prefix, JSONL round-trip, idempotency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>