feat(guardrail): Batches 1-4 — Agent industrial hardening - #169
Merged
Conversation
Covers TurnGuard configurability, sub-agent isolation, observability/API, and tool/context hardening. References Claude Code permission model and Codex CLI observability patterns.
8 steps, 26 files, ~200 lines. Covers TurnGuardConfig, ToolDomain flags, circuit breaker configurability, and mutex hardening.
…omain on all tools, replace hardcoded tool name lists Steps 1-4 of Batch 1.
…utex for TurnGuard and StallDetector Steps 5-7 of Batch 1.
Add 12 TurnGuard tests (config defaults, custom thresholds, nudge messages, warning count, reset) and 5 Batch 1 agent loop tests (circuit breaker threshold, ToolDomain classification/bitflags).
- profiles_ now protected by std::shared_mutex (unique_lock for writes, shared_lock for reads with cfg copy-out before create_sub_agent) - SubAgentRunner inherits enable_shared_from_this, async lambdas capture shared_from_this() instead of raw this - SubAgentConfig gains max_turns field (0 = use default of 10) - Each sub-agent gets an isolated MemoryStore (no shared parent state) - hardware_concurrency() guarded with std::max(1, ...) against zero - fan_out and sequential now handle per-task exceptions without losing completed results - AgentTool spawn: std::thread().detach() replaced with std::async + active_tasks_ map + get_result action + kMaxConcurrentSubAgents=8
…ts, HTTP protection
…struct, not nested)
…mpactor exception safety
…imit tests - test_tools.cpp: 4 new tests for argument validation (missing required, wrong type, valid args, no-schema tool) - test_agent_loop.cpp: 4 new tests for tool_timeout_ms, tool_rate_limit defaults - All 55 tests pass across 4 test binaries
8 fixes across 8 files: run_call_count_ reset, tool timeout abandoned-task pattern, fan_out error storage, ToolDomain-based tool restriction, dynamic reason messages, resume_run() execution launch, test fix, agent_tool capacity check reorder.
10 tasks across 3 parallel worktree groups, ~80 lines in 8 source files, plus 5 new regression tests.
…est, add regression tests - agent_tool: move std::async launch after capacity check inside mutex - test_tools: register ReadFileTool in empty-registry validation test - turn_guard: use config threshold in world-query reason message - Add regression tests: restricted_tools default, reason messages, fan_out error handling, run_call_count_
…xecute_run in resume_run()
…timeout, ToolDomain restrictions, dynamic reason messages
…ix 6) Resolved sub_agent_runner.cpp conflict: kept shared_from_this safety and hardware_concurrency-based max_parallel, added batch_start tracking for error-to-agent_id mapping in catch block.
…lDomain restrictions, dynamic reasons) Fix 1: reset run_call_count_ in run(), resume(), restore_history() Fix 2: abandoned-task container pattern (drain_abandoned_tasks, cancel token, overflow valve) Fix 4: ToolDomain-based tool restriction replaces hardcoded string list Fix 5: dynamic reason messages using config threshold values Added abandoned_tasks to RunMetrics Reverted WT-A duplicate ToolDomain/domain_of changes (already in Batch 1).
…meta include Clean up WT-A+WT-B merge artifacts: duplicate RunMetrics struct, duplicate resume_run declaration/definition, and missing tool_meta.hpp include in turn_guard.hpp for ToolDomain type.
Owner
Author
Review Bug Fixes Applied8 confirmed bugs from code review have been fixed and pushed:
Test results: 59/59 passed (AgentLoop: 26, TurnGuard: 14, SubAgentRunner: 9, Tools: 10) Design doc: |
…n text, eval_scene_completeness) - Adapt to synchronous run()/resume() return types (remove .get() calls) - Preserve our review fixes: restricted_domains_, run_call_count_ reset, abandoned_tasks - Add last_compaction_text_ member from main - Forward-declare eval_scene_completeness (main bug: used before definition) - Merge compaction logic: keep try/catch + metrics from our branch, last_compaction_text_ from main
ULookup
added a commit
that referenced
this pull request
Jun 21, 2026
Keep main's retry-safe text snapshots, llm_start timing, and improved exception logging from Agent industrial hardening batch.
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
Stats
Test plan