Stop attaching timestamps to LLM messages (#209)
Browse files* Strip internal message metadata before LLM calls
Co-authored-by: OpenAI Codex <codex@openai.com>
* Simplify timestamp handling for provider messages
Co-authored-by: OpenAI Codex <codex@openai.com>
* Remove timestamp metadata regression test
Co-authored-by: OpenAI Codex <codex@openai.com>
---------
Co-authored-by: OpenAI Codex <codex@openai.com>
Files changed (2)
256 unmodified lines25725825926026126226326466 unmodified lines331332333334335336337224 unmodified lines562563564565566567568256 unmodified lines"""Add a message to the history"""if token_count:self.running_context_usage = token_countif not getattr(message, "timestamp", None):message.timestamp = datetime.now().isoformat()self.items.append(message)if self.on_message_added:self.on_message_added(message)66 unmodified linescontent="Tool was not executed (interrupted or error).",tool_call_id=tc.id,name=tc.function.name,timestamp=datetime.now().isoformat(),))224 unmodified linessummarized_message = Message(role="assistant",content=summary,timestamp=datetime.now().isoformat(),)# Reconstruct: system + first user msg + summary + recent messages256 unmodified lines25725825926026126266 unmodified lines329330331332333334224 unmodified lines559560561562563564256 unmodified lines"""Add a message to the history"""if token_count:self.running_context_usage = token_countself.items.append(message)if self.on_message_added:self.on_message_added(message)66 unmodified linescontent="Tool was not executed (interrupted or error).",tool_call_id=tc.id,name=tc.function.name,))224 unmodified linessummarized_message = Message(role="assistant",content=summary,)# Reconstruct: system + first user msg + summary + recent messages
66 unmodified lines67686970717273747576777879808166 unmodified linesassert tool_msgs[0].content == "ok"def test_add_message_records_message_timestamp():cm = _make_cm()msg = Message(role="user", content="hello")cm.add_message(msg)assert getattr(cm.items[-1], "timestamp", None)def test_multiple_dangling_tool_calls_in_one_assistant_message_are_all_patched():cm = _make_cm()cm.items.extend([66 unmodified lines67686970717266 unmodified linesassert tool_msgs[0].content == "ok"def test_multiple_dangling_tool_calls_in_one_assistant_message_are_all_patched():cm = _make_cm()cm.items.extend([
agent/context_manager/manager.py-4
tests/unit/test_dangling_tool_calls.py-9