|
Entropic 2.3.8
Local-first agentic inference engine
|
Core agent execution engine. More...
#include <entropic/core/engine.h>
Classes | |
| struct | DelegationCallbacks |
| Grouped consumer-registered delegation callbacks (gh#29). More... | |
Public Member Functions | |
| AgentEngine (const InferenceInterface &inference, const LoopConfig &loop_config, const CompactionConfig &compaction_config) | |
| Construct an agent engine. | |
| std::vector< Message > | run (std::vector< Message > messages) |
| Run the engine on a set of messages. | |
| void | set_callbacks (const EngineCallbacks &callbacks) |
| Set callback functions for loop events. | |
| void | set_tool_executor (const ToolExecutionInterface &tool_exec) |
| Set the tool execution interface. | |
| void | set_tier_resolution (const TierResolutionInterface &tier_res) |
| Set the tier resolution interface for delegation. | |
| void | set_storage (const StorageInterface &storage) |
| Set the storage interface for persistence. | |
| void | set_hooks (const HookInterface &hooks) |
| Set the hook dispatch interface. | |
| void | set_project_dir (const std::filesystem::path &project_dir) |
| Set the configured project directory (gh#31, v2.1.6). | |
| void | set_stream_observer (TokenCallback observer, void *user_data) |
| Set the global stream observer. | |
| void | set_validation_provider (char *(*provider)(void *), void *user_data) |
| Register a JSON provider for the validation block in ON_COMPLETE hook context. | |
| 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) |
| Register delegation start/complete callbacks (gh#29, v2.1.5). | |
| DelegationCallbacks | delegation_callbacks_snapshot () const |
| Atomically snapshot the registered delegation callbacks. | |
| void | set_external_interrupt (void(*cb)(void *user_data), void *user_data) |
| Register a callback invoked alongside interrupt(). | |
| void | run_loop (LoopContext &ctx) |
| Run the engine loop on a pre-built context. | |
| const TierResolutionInterface & | tier_resolution () const |
| Get the tier resolution interface. | |
| void | interrupt () |
| Interrupt the running loop (thread-safe). | |
| void | reset_interrupt () |
| Reset interrupt flag for next run. | |
| void | pause () |
| Pause generation (thread-safe). | |
| void | cancel_pause () |
| Cancel pause and interrupt completely. | |
| std::pair< int, int > | context_usage (const std::vector< Message > &messages) const |
| Get context usage for a message list. | |
| EngineCallbacks & | callbacks () |
| Get mutable reference to engine callbacks. | |
| const LoopConfig & | loop_config () const |
| Get loop configuration. | |
| DirectiveProcessor & | directive_processor () |
| Get directive processor for external hook wiring. | |
| LoopMetrics | last_loop_metrics () const |
| Get metrics from the most recent completed run. | |
| std::unordered_map< std::string, LoopMetrics > | per_tier_metrics () const |
| Per-tier aggregated metrics since engine start. | |
| void | set_system_prompt (const std::string &prompt) |
| Set the system prompt for conversation state. | |
| void | set_session_logger (SessionLogger *logger) |
| Set session logger for model transcript logging. | |
| std::vector< Message > | run_turn (const std::string &input) |
| Run a single conversation turn (stateful). | |
| std::vector< Message > | run_turn (std::vector< Message > new_messages) |
| Run a single conversation turn from a pre-built message list (gh#37). | |
| void | seed_system_prompt (const std::vector< Message > &new_messages) |
| Prepend the configured system prompt if this turn needs it. | |
| bool | prepare_next_turn (std::vector< Message > &pending) |
Pull the next queued user message into pending (gh#40). | |
| int | run_streaming (const std::string &input, TokenCallback on_token, void *user_data, int *cancel_flag) |
| Run a streaming conversation turn (stateful). | |
| int | run_streaming (std::vector< Message > new_messages, TokenCallback on_token, void *user_data, int *cancel_flag) |
| Streaming conversation turn from a pre-built message list (gh#37). | |
| void | clear_conversation () |
| Clear conversation history. | |
| size_t | message_count () const |
| Get conversation message count. | |
| const std::vector< Message > & | get_messages () const |
| Get conversation messages (read-only). | |
| bool | queue_user_message (const std::string &message) |
| Append a user message to the mid-gen queue. | |
| size_t | user_message_queue_depth () const |
| Snapshot of the queue depth. | |
| void | clear_user_message_queue () |
| Drop all queued user messages. | |
| void | set_message_queue_capacity (int cap) |
| Set the runtime capacity of the mid-gen queue. | |
| bool | is_running () const |
| Whether a top-level run_turn is currently in progress. | |
| void | set_queue_observer (void(*observer)(const char *, size_t, void *), void *user_data) |
| Register an observer that fires when a queued user message is consumed and seeded as the next turn. | |
| void | set_state_observer (void(*observer)(int state, void *user_data), void *user_data) |
| Register a persistent state-transition observer. | |
| ToolExecutorHooks | build_directive_hooks () |
| Build ToolExecutorHooks wired to this engine's DirectiveProcessor. | |
| void | set_tier_info (const std::string &name, const ChildContextInfo &info) |
| Store pre-resolved tier context info. | |
| void | set_relay_single_delegate (const std::string &name) |
| Mark a tier as relay-on-single-delegate. | |
| void | set_handoff_rules (const std::unordered_map< std::string, std::vector< std::string > > &rules) |
| Store handoff rules for tier delegation. | |
| bool | tier_requires_explicit_completion (const std::string &tier) const |
| Check if a tier requires an explicit entropic.complete / entropic.delegate tool call to conclude its turn. | |
| bool | is_delegation_cycle (const LoopContext &ctx, const std::string &target) const |
| Check whether pending delegation would close a cycle. | |
| bool | is_delegation_repeat_blocked (const LoopContext &ctx, const std::string &target) const |
| Predicate: should this delegation be blocked because the same target has just failed too many times? (gh#64) | |
| int64_t | seconds_since_last_activity () const |
| gh#35: seconds since the engine last serviced a run(). | |
| bool | fold_complete_into_assistant (LoopContext &ctx, const Message &tool_result_msg) const |
| gh#68 (v2.3.4): fold entropic.complete summary into the prior assistant message, suppressing the JSON tool-result user message that would otherwise land in history. | |
Static Public Attributes | |
| static constexpr int | MAX_DELEGATION_DEPTH = 2 |
| Max delegation nesting depth (0=root, 1=child, 2=max). | |
Core agent execution engine.
Owns all engine subsystems: ResponseGenerator, ContextManager, CompactionManager, DirectiveProcessor. Implements the agentic loop (plan-act-observe-repeat) with proper state management and termination conditions.
| entropic::AgentEngine::AgentEngine | ( | const InferenceInterface & | inference, |
| const LoopConfig & | loop_config, | ||
| const CompactionConfig & | compaction_config | ||
| ) |
Construct an agent engine.
| inference | Inference interface (function pointers). |
| loop_config | Loop configuration. |
| compaction_config | Compaction configuration. |
| inference | Inference interface. |
| loop_config | Loop configuration. |
| compaction_config | Compaction configuration. |
Definition at line 133 of file engine.cpp.
| ToolExecutorHooks entropic::AgentEngine::build_directive_hooks | ( | ) |
Build ToolExecutorHooks wired to this engine's DirectiveProcessor.
Returns hooks with process_directives bridged to directive_processor(). Eliminates the need for facade bridge functions.
Definition at line 2934 of file engine.cpp.
|
inline |
Get mutable reference to engine callbacks.
Used by ToolExecutor which holds a reference that survives set_callbacks() reassignment (same pattern as ResponseGenerator).
| void entropic::AgentEngine::cancel_pause | ( | ) |
Cancel pause and interrupt completely.
Cancel pause and interrupt.
Definition at line 862 of file engine.cpp.
| void entropic::AgentEngine::clear_conversation | ( | ) |
| void entropic::AgentEngine::clear_user_message_queue | ( | ) |
Drop all queued user messages.
Drop all queued messages atomically.
@threadsafety Thread-safe.
Definition at line 2847 of file engine.cpp.
| std::pair< int, int > entropic::AgentEngine::context_usage | ( | const std::vector< Message > & | messages | ) | const |
Get context usage for a message list.
Get context usage.
| messages | Message list. |
| messages | Message list. |
Definition at line 875 of file engine.cpp.
| AgentEngine::DelegationCallbacks entropic::AgentEngine::delegation_callbacks_snapshot | ( | ) | const |
Atomically snapshot the registered delegation callbacks.
Hot path is execute_pending_delegation / execute_pending_pipeline: they grab the triple under the mutex once and pass it forward to the per-call DelegationManager. Prevents a torn read where the consumer reassigns the callbacks mid-delegation. (Hardening landed alongside the 2.1.5 verification pass.)
Definition at line 249 of file engine.cpp.
|
inline |
| bool entropic::AgentEngine::fold_complete_into_assistant | ( | LoopContext & | ctx, |
| const Message & | tool_result_msg | ||
| ) | const |
gh#68 (v2.3.4): fold entropic.complete summary into the prior assistant message, suppressing the JSON tool-result user message that would otherwise land in history.
gh#68 fold logic — see header.
Returns true when the message was folded (caller should NOT push it). Returns false when the message should be pushed as-is.
Conservative — only folds when ALL of:
msg.metadata["tool_name"] == "entropic.complete"ctx.messages.back() exists and has role == "assistant"content (typically the post-strip body when the model emitted only a tool_call)ctx.metadata["explicit_completion_summary"] is populated (set by dir_complete before this runs)If the model also emitted prose around the tool_call, the assistant body is non-empty and we leave both messages alone to avoid silently overwriting legitimate text.
Public so unit tests can exercise the predicate without spinning the full engine loop + mocking the tool executor.
@utility
@utility
Definition at line 710 of file engine.cpp.
| const std::vector< Message > & entropic::AgentEngine::get_messages | ( | ) | const |
Get conversation messages (read-only).
Get conversation messages.
Definition at line 2807 of file engine.cpp.
| void entropic::AgentEngine::interrupt | ( | ) |
Interrupt the running loop (thread-safe).
Interrupt the running loop.
Callable from any thread and polled per-token on the generation path, so interrupt() runs many times for a single Ctrl+C. Log only on the 0→1 transition to avoid flooding the session log. (P1-4, 2.0.6-rc16)
Definition at line 808 of file engine.cpp.
| bool entropic::AgentEngine::is_delegation_cycle | ( | const LoopContext & | ctx, |
| const std::string & | target | ||
| ) | const |
Check whether pending delegation would close a cycle.
Detect delegation cycles via ancestor chain check.
Exposed for unit tests. (P1-9, 2.0.6-rc16)
| ctx | Loop context (ancestor chain + locked tier). |
| target | Proposed delegation target tier. |
Targets already present in delegation_ancestor_tiers or matching the active locked_tier would re-enter an ancestor loop, which the depth cap only catches after repeated waste. (P1-9, 2.0.6-rc16)
| ctx | Loop context. |
| target | Pending delegation target tier name. |
Definition at line 684 of file engine.cpp.
| bool entropic::AgentEngine::is_delegation_repeat_blocked | ( | const LoopContext & | ctx, |
| const std::string & | target | ||
| ) | const |
Predicate: should this delegation be blocked because the same target has just failed too many times? (gh#64)
gh#64: predicate for the consecutive-failure cap.
Returns true when target matches ctx.last_failed_delegation_target and ctx.consecutive_failed_delegations >= loop_config_.max_consecutive_failed_delegations. Exposed so tests can exercise the guard without spinning a full child loop.
| ctx | Active loop context. |
| target | Proposed delegation target tier. |
See header. @utility
Definition at line 698 of file engine.cpp.
|
inline |
Whether a top-level run_turn is currently in progress.
Used by the facade to reject entropic_queue_user_message with ENTROPIC_ERROR_INVALID_STATE when there is no in-flight turn to "queue behind." Thread-safe (atomic load).
|
inline |
Get metrics from the most recent completed run.
Returns a copy of the LoopMetrics snapped at the end of the last call to run() or run_turn(). Zero-initialized before any run has completed. Thread-safe: read-only copy is returned. (P2-15)
|
inline |
| size_t entropic::AgentEngine::message_count | ( | ) | const |
Get conversation message count.
Definition at line 2797 of file engine.cpp.
| void entropic::AgentEngine::pause | ( | ) |
Pause generation (thread-safe).
Pause generation.
Definition at line 852 of file engine.cpp.
|
inline |
Per-tier aggregated metrics since engine start.
Keys are tier names ("lead", "eng", etc.). Values accumulate iterations/tool_calls/tokens_used/errors and sum duration_ms across every run_loop entered with that locked_tier. Empty map before any run. (P2-15 follow-up, 2.0.6-rc16.2)
| bool entropic::AgentEngine::prepare_next_turn | ( | std::vector< Message > & | pending | ) |
Pull the next queued user message into pending (gh#40).
Extracted from run_turn's drain loop. Pops one queued message, fires ON_QUEUE_CONSUMED, and replaces pending with it.
| pending | Out: cleared and set to the next user turn. |
| pending | Out: cleared and set to the next user turn. |
Definition at line 2603 of file engine.cpp.
| bool entropic::AgentEngine::queue_user_message | ( | const std::string & | message | ) |
Append a user message to the mid-gen queue.
Enqueue a user message subject to the configured cap.
Bounded FIFO. Enforces LoopConfig::message_queue_capacity. Drained between top-level run_turn invocations from inside run_turn itself — never at child-delegation boundaries.
| message | User input to enqueue. |
Definition at line 2818 of file engine.cpp.
| void entropic::AgentEngine::reset_interrupt | ( | ) |
Reset interrupt flag for next run.
Reset interrupt flag.
Definition at line 843 of file engine.cpp.
Run the engine on a set of messages.
Run the engine on initial messages.
| messages | Initial messages (system + user). |
| messages | System + user messages. |
Definition at line 370 of file engine.cpp.
| void entropic::AgentEngine::run_loop | ( | LoopContext & | ctx | ) |
Run the engine loop on a pre-built context.
Used by DelegationManager for child loops. Public so the delegation manager (same .so) can invoke it.
| ctx | Loop context to execute. |
| ctx | Loop context to execute. |
Definition at line 342 of file engine.cpp.
| int entropic::AgentEngine::run_streaming | ( | const std::string & | input, |
| TokenCallback | on_token, | ||
| void * | user_data, | ||
| int * | cancel_flag | ||
| ) |
Run a streaming conversation turn (stateful).
Same as run_turn but with streaming token output. Owns the StreamThinkFilter, cancel polling, and session logger wiring.
| input | User input string. |
| on_token | Consumer token callback (receives filtered UTF-8). |
| user_data | Consumer callback context. |
| cancel_flag | Polled per-token, nullable. |
| input | User input. |
| on_token | Consumer callback (filtered, UTF-8 aligned). |
| user_data | Consumer context. |
| cancel_flag | Polled per-token, nullable. |
Definition at line 2656 of file engine.cpp.
| int entropic::AgentEngine::run_streaming | ( | std::vector< Message > | new_messages, |
| TokenCallback | on_token, | ||
| void * | user_data, | ||
| int * | cancel_flag | ||
| ) |
Streaming conversation turn from a pre-built message list (gh#37).
Multimodal-aware streaming run_turn overload (gh#37, v2.1.8).
Multimodal-aware streaming overload. Same content_parts preservation semantics as run_turn(vector<Message>), with token callback wiring identical to the single-string streaming variant.
| new_messages | Messages to add this turn. |
| on_token | Consumer token callback (filtered UTF-8). |
| user_data | Consumer callback context. |
| cancel_flag | Polled per-token, nullable. |
Mirrors the single-string streaming variant — same stream filter, cancel polling, session logger wiring — but consumes a pre-built message list with content_parts preserved.
| new_messages | Messages to add this turn. |
| on_token | Filtered token callback. |
| user_data | Consumer context. |
| cancel_flag | Per-token cancel poll, nullable. |
Definition at line 2735 of file engine.cpp.
| std::vector< Message > entropic::AgentEngine::run_turn | ( | const std::string & | input | ) |
Run a single conversation turn (stateful).
Manages conversation history internally. Appends user message, runs the agentic loop, appends result messages.
| input | User input string. |
gh#40 (v2.1.10): after the agent loop reaches top-level COMPLETE, drains any messages enqueued mid-generation via queue_user_message as additional turns under the same call.
| input | User input string. |
Definition at line 2523 of file engine.cpp.
Run a single conversation turn from a pre-built message list (gh#37).
Run a stateful turn, draining any queued user messages (gh#40).
Multimodal-aware overload. Each message in new_messages is appended to the engine's conversation history with its content_parts preserved (no string flattening). The agentic loop runs over the full conversation; replies are appended to history and returned.
If the conversation is currently empty AND none of new_messages carries role == "system", the engine prepends its configured system_prompt_ first — matching the single-string overload's behavior.
| new_messages | Messages to add this turn (typically one user message; may include a system message on first turn). |
| new_messages | Messages to add this turn. |
Definition at line 2622 of file engine.cpp.
| int64_t entropic::AgentEngine::seconds_since_last_activity | ( | ) | const |
gh#35: seconds since the engine last serviced a run().
gh#35: idle accessor.
Updated at the entry of every run()/run_turn() call. Hosts that want an idle-exit policy poll this and tear down the engine when the value exceeds their threshold. Returned as int64 (epoch seconds delta) so consumers can compare against any unit.
See header. @utility
Definition at line 730 of file engine.cpp.
| void entropic::AgentEngine::seed_system_prompt | ( | const std::vector< Message > & | new_messages | ) |
Prepend the configured system prompt if this turn needs it.
Multimodal-aware run_turn overload (gh#37, v2.1.8).
Extracted from run_turn to keep it knots-clean. Seeds conversation_ with system_prompt_ only when the conversation is empty and the caller didn't supply its own system message.
| new_messages | The messages the caller is adding this turn. |
Takes a pre-built list of messages and preserves their content_parts end-to-end (no string flattening). Each input message is appended verbatim to the engine's conversation history before the agent loop runs. If the conversation is empty and the caller did not supply a system message, the engine's configured system_prompt_ is prepended first — matching the single-string overload's first-turn behavior.
| new_messages | Messages to add this turn. |
Prepend the configured system prompt if this turn needs it.
| new_messages | The messages the caller is adding this turn. |
Definition at line 2581 of file engine.cpp.
| void entropic::AgentEngine::set_callbacks | ( | const EngineCallbacks & | callbacks | ) |
Set callback functions for loop events.
| callbacks | Callback configuration. |
| callbacks | Callback configuration. |
Definition at line 158 of file engine.cpp.
| void entropic::AgentEngine::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 | ||
| ) |
Register delegation start/complete callbacks (gh#29, v2.1.5).
Replaces the pre-2.1.5 silent auto-merge-to-parent behavior. The engine stores these C-style function pointers and forwards them into every DelegationManager it constructs (one per pending delegation or pipeline). Null callbacks are honored: on_start null = always ACCEPT; on_complete null = default-deny (write patch to ~/.entropic/sandbox/<session>/pending/<id>.patch).
| on_start | Pre-delegation gate (nullable clears). |
| on_complete | Post-delegation result (nullable clears). |
| user_data | Forwarded to both callbacks. |
| on_start | Pre-delegation gate (nullable). |
| on_complete | Post-delegation result (nullable). |
| user_data | Forwarded to both callbacks. |
Definition at line 232 of file engine.cpp.
| void entropic::AgentEngine::set_external_interrupt | ( | void(*)(void *user_data) | cb, |
| void * | user_data | ||
| ) |
Register a callback invoked alongside interrupt().
Register external transport interrupt callback.
Used to propagate Ctrl+C into external MCP transports so in-flight tool calls do not run to completion. Facade wires this to ServerManager::interrupt_external_tools(). (P1-10, 2.0.6-rc16)
| cb | Callback (nullable). |
| user_data | Forwarded to cb. |
Facade wires this to ServerManager::interrupt_external_tools so AgentEngine::interrupt() unwinds tool dispatches within ~100ms. (P1-10, 2.0.6-rc16)
| cb | Callback (nullable). |
| user_data | Forwarded to cb. |
Definition at line 832 of file engine.cpp.
| void entropic::AgentEngine::set_handoff_rules | ( | const std::unordered_map< std::string, std::vector< std::string > > & | rules | ) |
Store handoff rules for tier delegation.
Store handoff rules.
| rules | Map of source tier → valid target tiers. |
| rules | Source tier → valid targets. |
Definition at line 2979 of file engine.cpp.
| void entropic::AgentEngine::set_hooks | ( | const HookInterface & | hooks | ) |
Set the hook dispatch interface.
| hooks | Hook dispatch interface (wired by facade). |
| hooks | Hook dispatch interface. |
Definition at line 201 of file engine.cpp.
| void entropic::AgentEngine::set_message_queue_capacity | ( | int | cap | ) |
Set the runtime capacity of the mid-gen queue.
Update the runtime cap (in-place on LoopConfig).
If cap is less than the current depth, excess pending messages are kept (no truncation) but no new enqueues succeed until the queue drains below the new cap. cap of 0 disables enqueue while leaving the queue otherwise functional.
| cap | New capacity. @threadsafety Thread-safe. |
Definition at line 2861 of file engine.cpp.
| void entropic::AgentEngine::set_project_dir | ( | const std::filesystem::path & | project_dir | ) |
Set the configured project directory (gh#31, v2.1.6).
Store the project_dir resolved by entropic_configure_dir.
The facade calls this from entropic_configure_dir after the layered config loader has resolved the project root. get_repo_dir() uses this value in preference to std::filesystem::current_path(), so consumers whose launcher cwd differs from the target project (the common case for wrapper CLIs and IDE plugins) still snapshot the right tree into the sandbox.
Pre-2.1.6 the engine used CWD unconditionally, silently ignoring the project_dir argument to entropic_configure_dir. Setting an empty path resets the override so get_repo_dir() falls back to CWD (preserves the no-configure-dir caller's behavior).
| project_dir | Project root (empty resets to CWD fallback). @threadsafety Serialized per-handle via the facade's api_mutex. |
gh#31 (v2.1.6). See engine.h for rationale. Resets the cache so a subsequent get_repo_dir() call picks up the new value even if a previous lookup already settled on the CWD fallback.
| project_dir | Project root (empty resets to CWD fallback). |
Definition at line 2329 of file engine.cpp.
| void entropic::AgentEngine::set_queue_observer | ( | void(*)(const char *, size_t, void *) | observer, |
| void * | user_data | ||
| ) |
Register an observer that fires when a queued user message is consumed and seeded as the next turn.
Persistent slot setter; survives set_callbacks() shuffles.
Persistent across set_callbacks() reassignments — the streaming entry points overwrite the EngineCallbacks struct per-call, so the queue observer needs a dedicated slot to survive both streaming and non-streaming runs.
| observer | Callback (consumed_text, remaining_depth, ud). Pass nullptr to clear. |
| user_data | Forwarded to observer. @threadsafety Thread-safe. |
Definition at line 2900 of file engine.cpp.
| void entropic::AgentEngine::set_relay_single_delegate | ( | const std::string & | name | ) |
Mark a tier as relay-on-single-delegate.
When this tier is the active (lead) tier and exactly one delegate completes successfully, the delegate's summary is used as the final output without lead re-generating. Avoids redundant re-synthesis of already user-ready delegate responses.
| name | Tier name (typically "lead"). |
| name | Tier name. |
Definition at line 2969 of file engine.cpp.
| void entropic::AgentEngine::set_session_logger | ( | SessionLogger * | log | ) |
Set session logger for model transcript logging.
| logger | Non-owning pointer (nullable). Must outlive engine. |
| log | Non-owning pointer (nullable). |
Definition at line 2507 of file engine.cpp.
| void entropic::AgentEngine::set_state_observer | ( | void(*)(int state, void *user_data) | observer, |
| void * | user_data | ||
| ) |
Register a persistent state-transition observer.
Wire the persistent state-observer slot.
The legacy path (EngineCallbacks::on_state_change) is wiped for the duration of run_streaming because that method replaces the full callback struct to install its token sink. This persistent slot survives every set_callbacks() shuffle so consumers (notably the external MCP bridge that the entropic_set_state_observer docstring names) actually see transitions during streaming runs.
Fires alongside the legacy on_state_change slot — neither supersedes the other. Pass nullptr to clear.
| observer | State-change callback. |
| user_data | Forwarded to observer. @threadsafety Thread-safe. |
Forwarded to ResponseGenerator so the PAUSED transition that ResponseGenerator emits during handle_pause also reaches the persistent slot. The legacy EngineCallbacks::on_state_change remains supported in parallel for in-tree callers (tests etc.).
Definition at line 2918 of file engine.cpp.
| void entropic::AgentEngine::set_storage | ( | const StorageInterface & | storage | ) |
Set the storage interface for persistence.
| storage | Storage callbacks (wired by facade). Nullable — engine works without storage (in-memory only mode). |
| storage | Storage callbacks (nullable). |
Definition at line 190 of file engine.cpp.
| void entropic::AgentEngine::set_stream_observer | ( | TokenCallback | observer, |
| void * | user_data | ||
| ) |
Set the global stream observer.
Fires for every token from every generation path — batch entropic_run, entropic_run_streaming, and delegate child-loop generations. Persists across per-call EngineCallbacks reassignment.
| observer | Token callback (nullable clears). |
| user_data | Forwarded to observer. |
Delegates to ResponseGenerator which owns the choke point for every generation path (streaming, batch, and child-loop delegations).
| observer | Token callback (nullable). |
| user_data | Forwarded to observer. |
Definition at line 219 of file engine.cpp.
| void entropic::AgentEngine::set_system_prompt | ( | const std::string & | prompt | ) |
Set the system prompt for conversation state.
| prompt | Assembled system prompt string. |
| prompt | Assembled system prompt. |
Definition at line 2497 of file engine.cpp.
| void entropic::AgentEngine::set_tier_info | ( | const std::string & | name, |
| const ChildContextInfo & | info | ||
| ) |
Store pre-resolved tier context info.
Called at configure time. The engine uses this data for delegation instead of external TierResolutionInterface callbacks.
| name | Tier name. |
| info | Pre-resolved context info (system prompt, tools, etc.). |
| name | Tier name. |
| info | Context info. |
Definition at line 2956 of file engine.cpp.
| void entropic::AgentEngine::set_tier_resolution | ( | const TierResolutionInterface & | tier_res | ) |
Set the tier resolution interface for delegation.
Set tier resolution interface for delegation.
| tier_res | Tier resolution callbacks (wired by facade). |
| tier_res | Tier resolution callbacks. |
Definition at line 179 of file engine.cpp.
| void entropic::AgentEngine::set_tool_executor | ( | const ToolExecutionInterface & | tool_exec | ) |
Set the tool execution interface.
| tool_exec | Tool execution interface (wired by facade). |
| tool_exec | Tool execution interface. |
Definition at line 168 of file engine.cpp.
| void entropic::AgentEngine::set_validation_provider | ( | char *(*)(void *) | provider, |
| void * | user_data | ||
| ) |
Register a JSON provider for the validation block in ON_COMPLETE hook context.
Register validation JSON provider for ON_COMPLETE context.
The callback returns a malloc'd JSON object describing the validator's most recent result: {ran, verdict, violations, revisions_applied} The engine copies and frees the returned buffer. NULL return or nullptr callback means no validation block is emitted. (E3, 2.0.6-rc17)
| provider | JSON builder (nullable clears). |
| user_data | Forwarded to provider. |
| provider | JSON builder callback (nullable). |
| user_data | Forwarded to provider. |
Definition at line 261 of file engine.cpp.
| bool entropic::AgentEngine::tier_requires_explicit_completion | ( | const std::string & | tier | ) | const |
Check if a tier requires an explicit entropic.complete / entropic.delegate tool call to conclude its turn.
Check if a tier contractually requires explicit completion.
Exposed for unit tests. (P1-6, 2.0.6-rc16)
| tier | Tier name. |
Delegates to the TierResolutionInterface, falling back to false when no resolver is wired (preserves legacy behavior in tests that omit tier metadata).
| tier | Tier name. |
Definition at line 663 of file engine.cpp.
| const TierResolutionInterface & entropic::AgentEngine::tier_resolution | ( | ) | const |
Get the tier resolution interface.
Definition at line 273 of file engine.cpp.
| size_t entropic::AgentEngine::user_message_queue_depth | ( | ) | const |
Snapshot of the queue depth.
Read queue depth under the queue mutex.
@threadsafety Thread-safe.
Definition at line 2837 of file engine.cpp.
|
staticconstexpr |