include/entropic/mcp/tool_call_history.h¶
include/entropic/mcp/tool_call_history.h
entropic::ToolCallHistory
Fixed-size ring buffer of recent tool calls.
entropic::ToolCallHistory::ToolCallHistory(size_t capacity=100)
Construct with buffer capacity.
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.
- Parameters
capacity— Maximum entries to retain (default 100).
void entropic::ToolCallHistory::record(const ToolCallRecord &entry)
Record a completed tool call.
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.
- Parameters
entry— Tool call record to store.entry— Tool call record — sequence, fully-qualified tool name, key-only params summary, status, truncated result summary, elapsed ms, error detail and loop iteration.
std::vector< ToolCallRecord > entropic::ToolCallHistory::recent(size_t count) const
Get the N most recent entries (newest first).
Takes the shared (reader) half of the mutex so several readers can run concurrently alongside a single writer.
- Parameters
count— Maximum entries to return.count— Maximum entries to return; clamped to the stored count.
- Returns
- Vector of records, newest first.
- Up to count records ordered newest-first, walking the ring backwards from the write head; empty when nothing is stored.
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).
- Returns
- Vector of all records.
- Every retained record oldest-first — at most capacity entries, the older ones having been overwritten.
std::string entropic::ToolCallHistory::to_json(size_t count) const
Serialize recent entries to JSON array string.
- Parameters
count— Maximum entries to include (0 = all).count— Maximum entries; 0 means "all", oldest-first.
- Returns
- JSON array of ToolCallRecord objects.
- Valid JSON array string honouring the count limit — oldest-first for count 0, newest-first otherwise; "[]" when nothing is stored.
size_t entropic::ToolCallHistory::size() const
Current number of stored entries.
- Returns
- Entry count (<= capacity).
- Number of retained records under a shared lock — rises to capacity and then stays there as older entries are overwritten.
entropic::ToolCallRecord
Lightweight record of a recent tool call for introspection.
size_t entropic::ToolCallRecord::sequence
Monotonic sequence number.
std::string entropic::ToolCallRecord::tool_name
Fully-qualified tool name.
std::string entropic::ToolCallRecord::params_summary
Top-level param keys only.
std::string entropic::ToolCallRecord::status
"success", "error", "timeout"
std::string entropic::ToolCallRecord::result_summary
First 200 chars of result.
double entropic::ToolCallRecord::elapsed_ms
Execution time in milliseconds.
std::string entropic::ToolCallRecord::error_detail
Error message if status != "success".
int entropic::ToolCallRecord::iteration
Loop iteration when called.