From 16bc7436c5fa9a4527b4f6a00c4b61d5db2e1597 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Tue, 10 Mar 2026 20:52:53 -0700 Subject: [PATCH] fix: raise observer analysis turn budget --- .../agents/observer-loop.sh | 13 ++++++++++++- tests/hooks/hooks.test.js | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/skills/continuous-learning-v2/agents/observer-loop.sh b/skills/continuous-learning-v2/agents/observer-loop.sh index 113a8eb0..f4aca82b 100755 --- a/skills/continuous-learning-v2/agents/observer-loop.sh +++ b/skills/continuous-learning-v2/agents/observer-loop.sh @@ -78,9 +78,20 @@ Rules: PROMPT timeout_seconds="${ECC_OBSERVER_TIMEOUT_SECONDS:-120}" + max_turns="${ECC_OBSERVER_MAX_TURNS:-10}" exit_code=0 - claude --model haiku --max-turns 3 --print < "$prompt_file" >> "$LOG_FILE" 2>&1 & + case "$max_turns" in + ''|*[!0-9]*) + max_turns=10 + ;; + esac + + if [ "$max_turns" -lt 4 ]; then + max_turns=10 + fi + + claude --model haiku --max-turns "$max_turns" --print < "$prompt_file" >> "$LOG_FILE" 2>&1 & claude_pid=$! ( diff --git a/tests/hooks/hooks.test.js b/tests/hooks/hooks.test.js index 8cbfa3ac..d0583138 100644 --- a/tests/hooks/hooks.test.js +++ b/tests/hooks/hooks.test.js @@ -2105,6 +2105,21 @@ async function runTests() { passed++; else failed++; + if ( + test('observer-loop uses a configurable max-turn budget with safe default', () => { + const observerLoopSource = fs.readFileSync( + path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'agents', 'observer-loop.sh'), + 'utf8' + ); + + assert.ok(observerLoopSource.includes('ECC_OBSERVER_MAX_TURNS'), 'observer-loop should allow max-turn overrides'); + assert.ok(observerLoopSource.includes('max_turns="${ECC_OBSERVER_MAX_TURNS:-10}"'), 'observer-loop should default to 10 turns'); + assert.ok(!observerLoopSource.includes('--max-turns 3'), 'observer-loop should not hardcode a 3-turn limit'); + }) + ) + passed++; + else failed++; + if ( await asyncTest('detect-project exports the resolved Python command for downstream scripts', async () => { const detectProjectPath = path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'scripts', 'detect-project.sh');