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>
agent/context_manager/manager.py
CHANGED
|
@@ -257,8 +257,6 @@ class ContextManager:
|
|
| 257 |
"""Add a message to the history"""
|
| 258 |
if token_count:
|
| 259 |
self.running_context_usage = token_count
|
| 260 |
-
if not getattr(message, "timestamp", None):
|
| 261 |
-
message.timestamp = datetime.now().isoformat()
|
| 262 |
self.items.append(message)
|
| 263 |
if self.on_message_added:
|
| 264 |
self.on_message_added(message)
|
|
@@ -331,7 +329,6 @@ class ContextManager:
|
|
| 331 |
content="Tool was not executed (interrupted or error).",
|
| 332 |
tool_call_id=tc.id,
|
| 333 |
name=tc.function.name,
|
| 334 |
-
timestamp=datetime.now().isoformat(),
|
| 335 |
)
|
| 336 |
)
|
| 337 |
|
|
@@ -562,7 +559,6 @@ class ContextManager:
|
|
| 562 |
summarized_message = Message(
|
| 563 |
role="assistant",
|
| 564 |
content=summary,
|
| 565 |
-
timestamp=datetime.now().isoformat(),
|
| 566 |
)
|
| 567 |
|
| 568 |
# Reconstruct: system + first user msg + summary + recent messages
|
|
|
|
| 257 |
"""Add a message to the history"""
|
| 258 |
if token_count:
|
| 259 |
self.running_context_usage = token_count
|
|
|
|
|
|
|
| 260 |
self.items.append(message)
|
| 261 |
if self.on_message_added:
|
| 262 |
self.on_message_added(message)
|
|
|
|
| 329 |
content="Tool was not executed (interrupted or error).",
|
| 330 |
tool_call_id=tc.id,
|
| 331 |
name=tc.function.name,
|
|
|
|
| 332 |
)
|
| 333 |
)
|
| 334 |
|
|
|
|
| 559 |
summarized_message = Message(
|
| 560 |
role="assistant",
|
| 561 |
content=summary,
|
|
|
|
| 562 |
)
|
| 563 |
|
| 564 |
# Reconstruct: system + first user msg + summary + recent messages
|
tests/unit/test_dangling_tool_calls.py
CHANGED
|
@@ -67,15 +67,6 @@ def test_no_orphan_means_no_stub():
|
|
| 67 |
assert tool_msgs[0].content == "ok"
|
| 68 |
|
| 69 |
|
| 70 |
-
def test_add_message_records_message_timestamp():
|
| 71 |
-
cm = _make_cm()
|
| 72 |
-
msg = Message(role="user", content="hello")
|
| 73 |
-
|
| 74 |
-
cm.add_message(msg)
|
| 75 |
-
|
| 76 |
-
assert getattr(cm.items[-1], "timestamp", None)
|
| 77 |
-
|
| 78 |
-
|
| 79 |
def test_multiple_dangling_tool_calls_in_one_assistant_message_are_all_patched():
|
| 80 |
cm = _make_cm()
|
| 81 |
cm.items.extend([
|
|
|
|
| 67 |
assert tool_msgs[0].content == "ok"
|
| 68 |
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def test_multiple_dangling_tool_calls_in_one_assistant_message_are_all_patched():
|
| 71 |
cm = _make_cm()
|
| 72 |
cm.items.extend([
|