85 const std::vector<ToolCall>& tool_calls);
94 static std::vector<ToolCall> sort_tool_calls(
95 const std::vector<ToolCall>& calls);
103 void extract_and_process_directives(
113 std::string check_duplicate(
const LoopContext& ctx,
126 const std::string& previous_result);
134 bool check_approval(
const ToolCall& call);
143 std::optional<Message> check_tier_allowed(
153 std::pair<Message, std::string> execute_tool(
169 void record_tool_history(
const ToolCall& call,
170 const std::string& args_json,
171 const std::string& result_text,
172 long long ms,
int iteration);
191 Message& msg,
const std::string& raw_result,
205 double exec_ms,
const std::string& raw_result,
214 static std::string tool_call_key(
const ToolCall& call);
225 const std::string& result);
235 const std::string& reason);
245 const std::string&
error);
262 void truncate_to_limit(std::vector<ToolCall>& calls,
int limit)
const;
292 std::optional<Message> check_schema(
const ToolCall& call);
302 std::optional<Message> check_dup_or_approval(
313 std::vector<Message> process_single_call(
325 const std::vector<Message>& results)
const;
341 static Message create_circuit_breaker_message();
351 static Message create_duplicate_message(
353 const std::string& previous_result);
362 static std::string serialize_args(
const ToolCall& call);
371 static std::string serialize_tool_call(
const ToolCall& call);
386 static std::string build_post_tool_json(
388 const std::string& raw_result,
390 const std::string& tier,
414 const std::string& tool_name);
429 int effective_hard_block_threshold()
const;
468 void apply_result_size_cap(std::string& content)
const;
479 static std::string build_pre_tool_json(
481 const std::string& tier,
513 const std::string& raw_result,
537 void fire_tool_complete_callback(
const ToolCall& call,
538 const std::string& result,
546 HookInterface hook_iface_;
548 std::atomic<size_t> history_seq_{0};
566 void set_hooks(
const HookInterface& hooks) { hook_iface_ = hooks; }
575 auth_mgr_ = auth_mgr;
589 std::optional<Message> check_mcp_authorization(
Mutable state carried through the agentic loop.