Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::DelegationManager Class Reference

Orchestrates child loop creation and execution. More...

#include <entropic/core/delegation.h>

Public Member Functions

 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.
 
void set_todo_callbacks (const TodoCallbacks &callbacks)
 Set todo list save/restore callbacks.
 
void set_dir_swap (ScopedSandbox::SwapDirFn swap_fn, void *user_data)
 Set directory swap callback for ScopedSandbox.
 
void set_storage (const struct StorageInterface *storage)
 Set storage interface for delegation record persistence.
 
void 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).
 
DelegationResult execute_delegation (LoopContext &parent_ctx, const std::string &target_tier, const std::string &task, std::optional< int > max_turns=std::nullopt)
 Run a child inference loop for the target tier.
 
DelegationResult 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)
 Resume a prior delegation with pre-loaded conversation history.
 
DelegationResult execute_pipeline (LoopContext &parent_ctx, const std::vector< std::string > &stages, const std::string &task)
 Run a multi-stage delegation pipeline sequentially.
 

Detailed Description

Orchestrates child loop creation and execution.

Builds a fresh LoopContext for the target tier, runs the engine's loop to completion, and extracts the final assistant message as the delegation result. Manages worktree lifecycle (create, merge, discard) and todo list save/restore across child contexts.

DelegationManager mgr(run_fn, ud, tier_res, repo_dir);
auto result = mgr.execute_delegation(parent_ctx, "eng", "Implement X");
// result.summary contains the child's final output
Orchestrates child loop creation and execution.
Definition delegation.h:105
Version
1.8.6

Definition at line 105 of file delegation.h.

Constructor & Destructor Documentation

◆ DelegationManager()

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_childCallback to run child engine loop.
run_child_dataOpaque pointer for run_child.
tier_resolutionTier resolution interface.
repo_dirOptional repo root (informational; used for ScopedSandbox dir-swap and storage record metadata).
sandbox_mgrNon-owning, engine-scoped sandbox manager. May be nullptr (delegation runs without an isolated sandbox).
Version
2.1.6
Parameters
run_childCallback to run child engine loop.
run_child_dataOpaque pointer for run_child.
tier_resolutionTier resolution interface.
repo_dirOptional project root (informational metadata).
sandbox_mgrNon-owning, engine-scoped sandbox manager.

Definition at line 40 of file delegation.cpp.

Member Function Documentation

◆ execute_delegation()

DelegationResult entropic::DelegationManager::execute_delegation ( LoopContext parent_ctx,
const std::string &  target_tier,
const std::string &  task,
std::optional< int >  max_turns = std::nullopt 
)

Run a child inference loop for the target tier.

Parameters
parent_ctxParent loop context.
target_tierTier name to delegate to.
taskTask description for the child.
max_turnsOptional iteration limit for child loop.
Returns
DelegationResult with summary, success, and child messages.
Version
1.8.6
Parameters
parent_ctxParent loop context.
target_tierTier name to delegate to.
taskTask description for the child.
max_turnsOptional iteration limit.
Returns
DelegationResult.

Definition at line 350 of file delegation.cpp.

◆ execute_pipeline()

DelegationResult entropic::DelegationManager::execute_pipeline ( LoopContext parent_ctx,
const std::vector< std::string > &  stages,
const std::string &  task 
)

Run a multi-stage delegation pipeline sequentially.

Parameters
parent_ctxParent loop context.
stagesOrdered list of tier names.
taskTask description (shared across stages).
Returns
DelegationResult from the final stage.
Version
1.8.6

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_ctxParent loop context.
stagesOrdered list of tier names.
taskTask description.
Returns
DelegationResult from the final stage.

Definition at line 547 of file delegation.cpp.

◆ execute_resume_delegation()

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 
)

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_ctxParent loop context.
target_tierTier resolved by the engine from storage.
taskNew sub-task to append to history.
seed_historyPre-loaded conversation messages.
max_turnsOptional iteration limit.
Returns
DelegationResult.
Version
2.1.6

Definition at line 452 of file delegation.cpp.

◆ set_delegation_callbacks()

void entropic::DelegationManager::set_delegation_callbacks ( ent_decision_t(*)(const ent_delegation_request_t *, void *)  on_start,
ent_decision_t(*)(const ent_delegation_result_t *, void *)  on_complete,
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_startPre-delegation gate (nullable).
on_completePost-delegation result (nullable).
user_dataForwarded to both callbacks.
Version
2.1.5
Parameters
on_startPre-delegation gate (nullable).
on_completePost-delegation result (nullable).
user_dataForwarded to both callbacks.

Definition at line 94 of file delegation.cpp.

◆ set_dir_swap()

void entropic::DelegationManager::set_dir_swap ( ScopedSandbox::SwapDirFn  swap_fn,
void *  user_data 
)

Set directory swap callback for ScopedSandbox.

Parameters
swap_fnDirectory swap callback.
user_dataOpaque pointer for swap_fn.
Version
2.1.5
Parameters
swap_fnDirectory swap callback.
user_dataOpaque pointer for swap_fn.

Definition at line 70 of file delegation.cpp.

◆ set_storage()

void entropic::DelegationManager::set_storage ( const struct StorageInterface storage)

Set storage interface for delegation record persistence.

Parameters
storageStorage callbacks (nullable).
Version
1.8.8
Parameters
storageStorage callbacks (nullable).

Definition at line 82 of file delegation.cpp.

◆ set_todo_callbacks()

void entropic::DelegationManager::set_todo_callbacks ( const TodoCallbacks callbacks)

Set todo list save/restore callbacks.

Parameters
callbacksTodo callbacks.
Version
1.8.6
Parameters
callbacksTodo callbacks.

Definition at line 59 of file delegation.cpp.


The documentation for this class was generated from the following files: