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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ the GitHub Release body, so a release with no entry here fails.

Versioning follows [docs/versioning.md](docs/versioning.md).

## [0.4.0] - 2026-09-03

### Added

- `ToolResult` now carries optional structured failure, recovery, and repeated-
invocation metadata. `ToolExecutionHooks.result_metadata` lets products
populate those fields without moving product-specific classifiers or stores
into AgentCore. Timeouts and exceptions receive stable core-owned
`error_kind` values.
- Loop observers can inspect the exact pre-provider LLM input, correlate calls
and retries through stable identifiers, and receive pre/post snapshots for
rollback, overflow recovery, and policy-driven context compaction.
- Products can dynamically constrain the tools available to an individual turn,
supply callable per-call addenda as system or user messages, customize tool
history rendering, and preserve host-owned recovery metadata.
- Deterministic and LLM-backed compaction now retain the original task,
tool-call/result pairing, recoverability references, and recovery-index order.

### Fixed

- Context-discard notifications now fire when overflow recovery replaces a
message without changing history length and when a custom compactor mutates
the history list in place.

## [0.3.0] - 2026-09-03

First published release. AgentCore is now open source under Apache-2.0 and
Expand Down
31 changes: 30 additions & 1 deletion agent_core/loop_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ class LoopConfig:
summary_prompt: str = ""

# Per-call reminder added to a copy of history, never persisted.
system_addendum_per_call: str = ""
system_addendum_per_call: str | Callable[[], str] = ""
system_addendum_min_turn: int = 0
system_addendum_per_call_role: str = "system"


@dataclass
Expand Down Expand Up @@ -306,6 +307,30 @@ class ToolResult:
is_error: bool
# Interrupted results remain in history to preserve tool-call pairing.
interrupted: bool = False
# Stable machine-readable failure category supplied by the execution
# engine or a host classifier. Empty for successful legacy tools.
error_kind: str = ""
# Opaque host-owned handle for a result body shed from model context.
result_id: str = ""
# Host-provided repeated-invocation metadata. Execution is never skipped.
repeat_count: int = 1
repeat_recovery_id: str = ""


@dataclass
class ContextCompactionContext:
"""Pre/post snapshot for any loop operation that discards history."""

turn: int
task_id: str
role_id: str
reason: str
compactor: str
policy: str
messages_before: list[Message]
messages_after: list[Message]
tokens_before: int
metadata: dict[str, Any]


@dataclass
Expand Down Expand Up @@ -472,6 +497,9 @@ async def on_compaction(self, event: CompactionEvent) -> None:
"""History was rewritten. Passive: compaction has already happened by
the time this runs, so there is no intervention to return."""

async def on_context_compacted(self, ctx: ContextCompactionContext) -> None:
"""History was discarded while its pre-change form was still reachable."""

async def on_loop_end(self, result: AgentLoopResult) -> None:
pass

Expand Down Expand Up @@ -689,6 +717,7 @@ async def notify_tool_result(
"CancellationObserver",
"CompactionEvent",
"CompactionObserver",
"ContextCompactionContext",
"Intervention",
"LLMAttemptContext",
"LLMDeltaContext",
Expand Down
Loading