include/entropic/core/delegation.h¶
include/entropic/core/delegation.h
Types
using entropic::RunChildLoopFn = typedef void (*)(LoopContext& ctx, void* user_data) hook point
Callback type for running a child engine loop.
The engine provides this so DelegationManager can spawn child loops without a circular dependency on AgentEngine's full interface.
- Parameters
ctx— Child loop context.user_data— Opaque pointer (AgentEngine instance).
entropic::DelegationManager
Orchestrates child loop creation and execution.
entropic::DelegationManager::DelegationManager(RunChildLoopFn run_child, void *run_child_data, const TierResolutionInterface &tier_resolution, const std::filesystem::path &repo_dir={}, SandboxManager *sandbox_mgr=nullptr)
Construct with engine loop callback and tier resolution.
gh#33 (v2.1.6): pre-2.1.6 this constructor owned a fresh SandboxManager per delegation. The manager is now engine-scoped and supplied as a non-owning pointer by the caller (AgentEngine); passing nullptr disables sandboxing for the delegation.
- Parameters
run_child— Callback to run child engine loop.run_child_data— Opaque pointer for run_child.tier_resolution— Tier resolution interface.repo_dir— Optional repo root (informational; used for ScopedSandbox dir-swap and storage record metadata).sandbox_mgr— Non-owning, engine-scoped sandbox manager. May be nullptr (delegation runs without an isolated sandbox).repo_dir— Optional project root (informational metadata).sandbox_mgr— Non-owning, engine-scoped sandbox manager.
void entropic::DelegationManager::set_todo_callbacks(const TodoCallbacks &callbacks)
Set todo list save/restore callbacks.
- Parameters
callbacks— Todo callbacks.
void entropic::DelegationManager::set_dir_swap(ScopedSandbox::SwapDirFn swap_fn, void *user_data)
Set directory swap callback for ScopedSandbox .
- Parameters
swap_fn— Directory swap callback.user_data— Opaque pointer for swap_fn.
void entropic::DelegationManager::set_storage(const struct StorageInterface *storage)
Set storage interface for delegation record persistence.
- Parameters
storage— Storage callbacks (nullable).
void entropic::DelegationManager::set_delegation_callbacks(ent_decision_t(*on_start)(const ent_delegation_request_t *, void *), ent_decision_t(*on_complete)(const ent_delegation_result_t *, void *), void *user_data)
Set delegation start/complete callbacks (gh#29, v2.1.5).
Set delegation start/complete callbacks. Forwarded by the engine from entropic_set_delegation_callbacks. on_start is invoked before each child loop runs and may veto the delegation (REJECT). on_complete receives the sandbox patch artifact; ACCEPT means the consumer applied it (sandbox is discarded), REJECT or NULL means the engine writes the patch to <session>/pending/<id>.patch as a default-deny fallback.
- Parameters
on_start— Pre-delegation gate (nullable).on_complete— Post-delegation result (nullable).user_data— Forwarded to both callbacks.
DelegationResult entropic::DelegationManager::execute_delegation(LoopContext &parent_ctx, const std::string &target_tier, const std::string &task, std::optional< int > max_turns=std::nullopt, const std::vector< ContextRef > &context={})
Run a child inference loop for the target tier.
- Parameters
parent_ctx— Parent loop context.target_tier— Tier name to delegate to.task— Task description for the child.max_turns— Optional iteration limit for child loop.max_turns— Optional iteration limit.
- Returns
- DelegationResult with summary, success, and child messages.
- DelegationResult.
DelegationResult entropic::DelegationManager::execute_resume_delegation(LoopContext &parent_ctx, const std::string &target_tier, const std::string &task, std::vector< Message > seed_history, std::optional< int > max_turns=std::nullopt, const std::vector< ContextRef > &context={})
Resume a prior delegation with pre-loaded conversation history.
Run a resumed child delegation with seed history (gh#32, v2.1.6). gh#32 (v2.1.6): Seeds the child context with seed_history (loaded from storage by the engine), then appends the supplied task as a fresh user message. Subsequent run_child semantics are identical to execute_delegation. The first system message from the loaded history is preserved; if absent, the tier's default system prompt is prepended so the child still has its identity context.
- Parameters
parent_ctx— Parent loop context.target_tier— Tier resolved by the engine from storage.task— New sub-task to append to history.seed_history— Pre-loaded conversation messages.max_turns— Optional iteration limit.
- Returns
- DelegationResult.
- DelegationResult for the resumed child run, or the early result produced when a precondition check fails.
DelegationResult entropic::DelegationManager::execute_pipeline(LoopContext &parent_ctx, const std::vector< std::string > &stages, const std::string &task, std::vector< DelegationResult > &stage_log, const std::vector< ContextRef > &context={})
Run a multi-stage delegation pipeline sequentially.
Issue #11 (v2.1.4): each stage now receives the prior stage's output as a [PRIOR STAGE OUTPUT] block in its task message (forward-carry semantics — the original intent that pre-2.1.4 was lost to per-stage isolation).
- Parameters
parent_ctx— Parent loop context.stages— Ordered list of tier names.task— Task description (shared across stages).stage_log— [out] Per-stage results appended in order.task— Task description.
- Returns
- DelegationResult from the final stage.
entropic::DelegationResult
Result returned from a child delegation loop.
std::string entropic::DelegationResult::summary
Final summary from child.
bool entropic::DelegationResult::success
Whether child reached COMPLETE via real entropic.complete.
std::string entropic::DelegationResult::target_tier
Tier that executed.
std::string entropic::DelegationResult::task
Original task text.
int entropic::DelegationResult::turns_used
Iterations consumed.
std::vector<Message> entropic::DelegationResult::child_messages
Full child message history.
std::string entropic::DelegationResult::terminal_reason
Non-empty when the child terminated synthetically rather than via a real entropic.complete.
Current value: "budget_exhausted" — set by AgentEngine::loop when max_iterations is hit and a forced synthetic complete is injected. Empty string = natural completion. (E7, 2.0.6-rc18)
bool entropic::DelegationResult::coverage_gap
Issue #10 (v2.1.4): coverage_gap signal from the child's entropic.complete call.
When true, the parent engine SUPPRESSES auto-relay and instead injects a [COVERAGE GAP] user message into the lead context so lead can chain to a follow-up specialist.
std::string entropic::DelegationResult::gap_description
Issue #10 (v2.1.4): concrete description of what the child's answer DOES NOT cover.
Required when coverage_gap=true (validated at the tool boundary in CompleteTool::execute).
std::vector<std::string> entropic::DelegationResult::suggested_files
Issue #10 (v2.1.4): file paths the lead should inspect to fill the coverage gap.
Only populated when coverage_gap=true.
entropic::TodoCallbacks
Callback type for saving/restoring todo list state.
std::string(* entropic::TodoCallbacks::save) (void *user_data)
Save current todo list state. Returns opaque state string.
void(* entropic::TodoCallbacks::install_fresh) (void *user_data)
Install a fresh empty todo list for child.
void(* entropic::TodoCallbacks::restore) (const std::string &saved, void *user_data)
Restore a previously saved todo list state.
void* entropic::TodoCallbacks::user_data
Opaque pointer (facade context)