Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/agents/_run_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def process_model_response(
shell_calls.append(ToolRunShellCall(tool_call=output, shell_tool=shell_tool))
continue
if output_type == "compaction":
items.append(CompactionItem(raw_item=cast(dict[str, Any], output), agent=agent))
items.append(CompactionItem(raw_item=cast(TResponseInputItem, output), agent=agent))
continue
if output_type == "apply_patch_call":
items.append(ToolCallItem(raw_item=cast(Any, output), agent=agent))
Expand Down
10 changes: 2 additions & 8 deletions src/agents/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,14 @@ class MCPApprovalResponseItem(RunItemBase[McpApprovalResponse]):


@dataclass
class CompactionItem:
class CompactionItem(RunItemBase[TResponseInputItem]):
"""Represents a compaction item from responses.compact."""

agent: Agent[Any]
"""The agent whose run caused this item to be generated."""

raw_item: dict[str, Any]
"""The raw compaction item containing encrypted_content."""

type: Literal["compaction_item"] = "compaction_item"

def to_input_item(self) -> TResponseInputItem:
"""Converts this item into an input item suitable for passing to the model."""
return cast(TResponseInputItem, self.raw_item)
return self.raw_item


RunItem: TypeAlias = Union[
Expand Down