Repository navigation
fix: Agent infrastructure critical issues (C3, C4, H1-H5) - #162
Merged
Merged
Conversation
Add read_mutex_ to serialize concurrent read_message calls from std::async tasks sharing the same stdout pipe. Add 30s timeout wrapper via wait_for to prevent indefinite blocking if the child process hangs.
- Change run()/resume() return type from future to direct AgentResponse (all callers immediately .get(), async added no benefit) - Delete move constructor/assignment (AgentLoop holds this in async paths) - Track last compaction summary for checkpoint recovery - Serialize actual tool calls and pipeline stats in checkpoint instead of hardcoded empty strings
Prevents std::bad_function_call when callers invoke without checking. Existing callers already guard with operator bool(); this is defense-in-depth.
Replace [this] capture in init_runtime with explicit SubRunDeps struct, matching the PipelineManager::Dependencies DI pattern. execute_sub_run is now a static method taking explicit dependencies. This eliminates the hidden lifetime dependency on Application member declaration order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_mutex_toJsonRpcClient::read_message()to serialize concurrent reads fromstd::asynctasks sharing the same stdout pipesend_request()to prevent indefinite blocking on hung child processAgentLoop::run()/resume()return type fromstd::future<AgentResponse>toAgentResponse(all callers immediately.get()— async added no benefit but created dangling reference risk)AgentLoopmove constructor/assignment (the object holdsthisin async paths)last_compaction_text_for recovery[this]capture ininit_runtimewith explicitSubRunDepsstruct (matchingPipelineManager::DependenciesDI pattern)PlanInput::on_escalateto[]{}to preventstd::bad_function_callFiles Changed
libs/core/include/merak/json_rpc_client.hpp— C3: addread_mutex_libs/core/src/json_rpc_client.cpp— C3: lock read_message + H4: 30s timeoutlibs/loop/include/merak/agent_loop.hpp— C4: sync return + H1: delete move + H2:last_compaction_text_libs/loop/src/agent_loop.cpp— C4: sync bodies + H2: checkpoint serialization + compaction trackinglibs/app/src/application.cpp— C4: remove.get()+ H3: SubRunDeps DIlibs/loop/src/sub_agent_runner.cpp— C4: remove.get()libs/app/include/merak/app/application.hpp— H3: SubRunDeps struct + static execute_sub_runlibs/core/include/merak/pipeline_types.hpp— H5: default initTest plan
on_escalateno longer throwsstd::bad_function_call