Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""Client-facing projection helpers for model-only compaction carriers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from agent.context_compressor import (
|
||||
ContextCompressor,
|
||||
is_compaction_summary_message,
|
||||
)
|
||||
|
||||
|
||||
_COMPACTION_INTERNAL_FIELDS = (
|
||||
"tool_calls",
|
||||
"finish_reason",
|
||||
"reasoning",
|
||||
"reasoning_content",
|
||||
"reasoning_details",
|
||||
"codex_reasoning_items",
|
||||
"codex_message_items",
|
||||
)
|
||||
|
||||
|
||||
def project_compaction_message_for_display(
|
||||
message: Dict[str, Any],
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Return authentic transcript content, or ``None`` for a pure handoff.
|
||||
|
||||
Model-facing recovery history retains the complete carrier. Display
|
||||
projections instead remove the handoff, inherited tool state, and internal
|
||||
reasoning while preserving any real prior-tail content or live user ask
|
||||
embedded in the carrier.
|
||||
"""
|
||||
if not isinstance(message, dict):
|
||||
return None
|
||||
if not is_compaction_summary_message(message):
|
||||
return message.copy()
|
||||
|
||||
projected = ContextCompressor._strip_context_summary_handoff_message(message)
|
||||
if projected is None:
|
||||
return None
|
||||
|
||||
projected = projected.copy()
|
||||
for key in _COMPACTION_INTERNAL_FIELDS:
|
||||
projected.pop(key, None)
|
||||
projected.pop("display_kind", None)
|
||||
return projected
|
||||
Reference in New Issue
Block a user