93 const std::unordered_map<std::string,
94 std::vector<std::string>>* map) {
95 tier_allowed_tools_ = map;
107 const std::vector<ToolCall>& tool_calls);
116 static std::vector<ToolCall> sort_tool_calls(
117 const std::vector<ToolCall>& calls);
125 void extract_and_process_directives(
135 std::string check_duplicate(
const LoopContext& ctx,
148 const std::string& previous_result);
156 bool check_approval(
const ToolCall& call);
165 std::optional<Message> check_tier_allowed(
175 std::pair<Message, std::string> execute_tool(
191 void record_tool_history(
const ToolCall& call,
192 const std::string& args_json,
193 const std::string& result_text,
194 long long ms,
int iteration);
213 Message& msg,
const std::string& raw_result,
227 double exec_ms,
const std::string& raw_result,
236 static std::string tool_call_key(
const ToolCall& call);
247 const std::string& result);
257 const std::string& reason);
267 const std::string&
error);
284 void truncate_to_limit(std::vector<ToolCall>& calls,
int limit)
const;
314 std::optional<Message> check_schema(
const ToolCall& call);
324 std::optional<Message> check_dup_or_approval(
335 std::vector<Message> process_single_call(
347 const std::vector<Message>& results)
const;
363 static Message create_circuit_breaker_message();
373 static Message create_duplicate_message(
375 const std::string& previous_result);
384 static std::string serialize_args(
const ToolCall& call);
393 static std::string serialize_tool_call(
const ToolCall& call);
408 static std::string build_post_tool_json(
410 const std::string& raw_result,
412 const std::string& tier,
436 const std::string& tool_name);
451 int effective_hard_block_threshold()
const;
490 void apply_result_size_cap(std::string& content)
const;
501 static std::string build_pre_tool_json(
503 const std::string& tier,
535 const std::string& raw_result,
559 void fire_tool_complete_callback(
const ToolCall& call,
560 const std::string& result,
571 const std::unordered_map<std::string, std::vector<std::string>>*
572 tier_allowed_tools_ =
nullptr;
573 HookInterface hook_iface_;
575 std::atomic<size_t> history_seq_{0};
593 void set_hooks(
const HookInterface& hooks) { hook_iface_ = hooks; }
602 auth_mgr_ = auth_mgr;
616 std::optional<Message> check_mcp_authorization(
Mutable state carried through the agentic loop.