|
Entropic 2.11.1
Local-first agentic inference engine
|
Fixed-size ring buffer of recent tool calls. More...
#include <entropic/mcp/tool_call_history.h>
Public Member Functions | |
| ToolCallHistory (size_t capacity=100) | |
| Construct with buffer capacity. | |
| void | record (const ToolCallRecord &entry) |
| Record a completed tool call. | |
| std::vector< ToolCallRecord > | recent (size_t count) const |
| Get the N most recent entries (newest first). | |
| std::vector< ToolCallRecord > | all () const |
| Get all stored entries (oldest first, insertion order). | |
| std::string | to_json (size_t count) const |
| Serialize recent entries to JSON array string. | |
| size_t | size () const |
| Current number of stored entries. | |
Fixed-size ring buffer of recent tool calls.
Capacity set at construction (default 100). When full, oldest entries are overwritten. Thread-safe reads via shared_mutex.
Definition at line 62 of file tool_call_history.h.
|
explicit |
Construct with buffer capacity.
| capacity | Maximum entries to retain (default 100). |
The buffer is allocated once, up front, and never grows — this is a bounded diagnostic window (backing entropic.diagnose / entropic.inspect and the validator's retry enrichment), explicitly NOT the audit log.
| capacity | Maximum entries to retain (default 100). @req REQ-MCP-020 |
Definition at line 30 of file tool_call_history.cpp.
| std::vector< ToolCallRecord > entropic::ToolCallHistory::all | ( | ) | const |
Get all stored entries (oldest first, insertion order).
Get all stored entries in insertion (oldest-first) order.
Shared-lock read. Handles both the not-yet-wrapped case (start at 0) and the wrapped case (start at the write head, which is the oldest surviving slot).
Definition at line 97 of file tool_call_history.cpp.
| std::vector< ToolCallRecord > entropic::ToolCallHistory::recent | ( | size_t | count | ) | const |
Get the N most recent entries (newest first).
| count | Maximum entries to return. |
Takes the shared (reader) half of the mutex so several readers can run concurrently alongside a single writer.
| count | Maximum entries to return; clamped to the stored count. |
count records ordered newest-first, walking the ring backwards from the write head; empty when nothing is stored. @req REQ-MCP-020 Definition at line 72 of file tool_call_history.cpp.
| void entropic::ToolCallHistory::record | ( | const ToolCallRecord & | entry | ) |
Record a completed tool call.
| entry | Tool call record to store. |
Takes the unique (writer) half of the shared_mutex. When the buffer is full the oldest record is overwritten in place, so size saturates at capacity rather than growing.
| entry | Tool call record — sequence, fully-qualified tool name, key-only params summary, status, truncated result summary, elapsed ms, error detail and loop iteration. @req REQ-MCP-020 |
Definition at line 49 of file tool_call_history.cpp.
| size_t entropic::ToolCallHistory::size | ( | ) | const |
Current number of stored entries.
Definition at line 160 of file tool_call_history.cpp.
| std::string entropic::ToolCallHistory::to_json | ( | size_t | count | ) | const |
Serialize recent entries to JSON array string.
| count | Maximum entries to include (0 = all). |
| count | Maximum entries; 0 means "all", oldest-first. |
Definition at line 144 of file tool_call_history.cpp.