@yasaswy.nagavolu/agents 0.16.6 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/bin/cli.js +0 -0
  2. package/content/agents/idea-agent/council_fanout.py +34 -7
  3. package/content/agents/idea-agent/test_council_fanout.py +33 -3
  4. package/content/agents/plan-agent/plan_council_fanout.py +40 -9
  5. package/content/agents/plan-agent/test_plan_council_fanout.py +72 -2
  6. package/content/agents/review-agent/review_council_fanout.py +31 -7
  7. package/content/agents/review-agent/test_review_council_fanout.py +37 -3
  8. package/content/agents/scribe-agent/scribe_runner.py +2 -2
  9. package/content/global/CLAUDE.md +16 -19
  10. package/content/global/hooks/permission_mode_guard.py +144 -0
  11. package/content/global/keybindings.json +13 -0
  12. package/content/global/rules/ui-spacing.md +29 -0
  13. package/content/hooks/tracker_proof_gate.py +29 -1
  14. package/content/manifest.json +111 -10
  15. package/content/proxy/README.md +50 -4
  16. package/content/proxy/artifact_mocker_gate.py +1 -1
  17. package/content/proxy/bg_process_reaper_hook.py +19 -0
  18. package/content/proxy/bg_process_registry.py +107 -3
  19. package/content/proxy/credential_mutation_guard.py +1 -1
  20. package/content/proxy/execution_worker_review_gate.py +113 -6
  21. package/content/proxy/git_shell_parse.py +868 -0
  22. package/content/proxy/grilling_format_gate.py +298 -0
  23. package/content/proxy/litellm/config.yaml +92 -16
  24. package/content/proxy/litellm/docker-compose.yml +1 -0
  25. package/content/proxy/portal/README.md +33 -0
  26. package/content/proxy/portal/register-autostart.ps1 +76 -0
  27. package/content/proxy/portal/supervise_portal_hidden.vbs +21 -0
  28. package/content/proxy/route_lock.py +103 -1
  29. package/content/proxy/shared_worktree_revert_guard.py +795 -0
  30. package/content/proxy/switch_model.ps1 +1 -1
  31. package/content/skills/html-mocker/annotate.js +15 -4
  32. package/content/skills/mattpocock-grilling/SKILL.md +1 -1
  33. package/content/skills/mattpocock-to-tickets/gitlab_phase.py +28 -8
  34. package/content/skills/mattpocock-to-tickets/tests/test_gitlab_phase.py +57 -4
  35. package/content/skills/publish-article/SKILL.md +13 -9
  36. package/content/skills/publish-article/bundle_skill.py +10 -11
  37. package/content/skills/publish-article/publish_article.py +27 -7
  38. package/content/skills/publish-article/tests/test_publish_article.py +28 -8
  39. package/content/skills/session-trace/SKILL.md +1 -0
  40. package/content/skills/session-trace/test_trace.py +148 -0
  41. package/content/skills/session-trace/trace.py +38 -1
  42. package/content/skills/switch-model/README.md +1 -1
  43. package/content/statusline/statusline-command.ps1 +83 -50
  44. package/content/statusline/statusline-command.py +168 -0
  45. package/content/statusline/subagent-statusline-command.ps1 +105 -0
  46. package/content/statusline/subagent-statusline-command.py +89 -0
  47. package/lib/install.js +1 -1
  48. package/lib/selfProfile.js +9 -3
  49. package/lib/update.js +1 -1
  50. package/lib/wiring.js +35 -11
  51. package/package.json +1 -1
package/bin/cli.js CHANGED
File without changes
@@ -84,7 +84,25 @@ def build_prompt(goal, context):
84
84
  return PANEL_PROMPT_NO_CONTEXT.format(goal=goal)
85
85
 
86
86
 
87
- def call_litellm(prompt, key, model, max_tokens=4000):
87
+ # DeepSeek-only addendum: the shared "No length limit" instruction above causes
88
+ # DeepSeek specifically to reliably fill the entire max_tokens budget regardless
89
+ # of prompt scope (confirmed via real calls on 2026-08-25 — it maxed out both a
90
+ # 16000 and a 24000 cap on both a broad and a narrow prompt), which reads as a
91
+ # truncation error in the call log every round. Gemini/Qwen/GLM don't show this
92
+ # behavior, so only DeepSeek's prompt gets this addendum — the other panels keep
93
+ # the unmodified "no length limit" instruction.
94
+ DEEPSEEK_BUDGET_ADDENDUM = """
95
+
96
+ Budget your answer to conclude cleanly within roughly 16,000-20,000 tokens. \
97
+ Prioritize depth on the highest-leverage points over exhaustive coverage of every \
98
+ possible angle — a focused, complete answer beats a broader one cut off mid-thought."""
99
+
100
+
101
+ def build_deepseek_prompt(prompt):
102
+ return prompt + DEEPSEEK_BUDGET_ADDENDUM
103
+
104
+
105
+ def call_litellm(prompt, key, model, max_tokens=4000, timeout=90):
88
106
  url = "http://127.0.0.1:4000/chat/completions"
89
107
  body = json.dumps({
90
108
  "model": model,
@@ -98,7 +116,7 @@ def call_litellm(prompt, key, model, max_tokens=4000):
98
116
  })
99
117
  start = time.monotonic()
100
118
  try:
101
- with urllib.request.urlopen(req, timeout=90) as r:
119
+ with urllib.request.urlopen(req, timeout=timeout) as r:
102
120
  d = json.load(r)
103
121
  choice = d["choices"][0]
104
122
  msg = choice["message"]
@@ -120,7 +138,7 @@ def call_litellm(prompt, key, model, max_tokens=4000):
120
138
  return PanelResult.failure(model, e, time.monotonic() - start)
121
139
 
122
140
 
123
- def call_litellm_stream(prompt, key, model, max_tokens=4000):
141
+ def call_litellm_stream(prompt, key, model, max_tokens=4000, timeout=90):
124
142
  """Streaming variant required by models whose upstream rejects non-streaming
125
143
  (e.g. litellm_qwen via Together AI). Accumulates delta.content chunks."""
126
144
  url = "http://127.0.0.1:4000/chat/completions"
@@ -139,7 +157,7 @@ def call_litellm_stream(prompt, key, model, max_tokens=4000):
139
157
  parts = []
140
158
  truncated = False
141
159
  try:
142
- with urllib.request.urlopen(req, timeout=90) as r:
160
+ with urllib.request.urlopen(req, timeout=timeout) as r:
143
161
  for raw_line in r:
144
162
  line = raw_line.decode("utf-8", "ignore").strip()
145
163
  if not line or not line.startswith("data: "):
@@ -185,7 +203,7 @@ def main():
185
203
  usage_msg="Usage: council_fanout.py 'raw goal' ['context']")
186
204
 
187
205
  # Fail fast: if the proxy itself is unreachable, every panel below will fail
188
- # the same way after its own (60-90s) timeout. Detect that in ~1 request.
206
+ # the same way after its own (90-240s) timeout. Detect that in ~1 request.
189
207
  down_reason = preflight_proxy(or_key, caller="idea-council")
190
208
  if down_reason:
191
209
  render_and_exit([
@@ -193,9 +211,18 @@ def main():
193
211
  for m in (GEMINI_MODEL, DEEPSEEK_MODEL, QWEN_MODEL, GLM_MODEL)
194
212
  ])
195
213
 
214
+ # Gemini and DeepSeek get raised max_tokens + timeout: Gemini's synthesis
215
+ # routinely runs 7-8k completion tokens (was hitting the old 8000 cap —
216
+ # observed truncation at 7669 and 7996 tokens on 2026-08-25), and DeepSeek
217
+ # is a reasoning model whose answers on multi-part goals regularly exceed
218
+ # the old 90s non-streaming request window AND the old 12000-token cap
219
+ # (observed a hard timeout at 90.02s and a max_tokens truncation at 95.62s
220
+ # the same day; a real 2026-08-25 proof call still truncated at 16000
221
+ # tokens after 164.91s, confirming 16000 is also too tight). Qwen and GLM
222
+ # have shown no timeout/truncation failures at their current limits.
196
223
  with concurrent.futures.ThreadPoolExecutor(max_workers=4) as ex:
197
- f_gemini = ex.submit(call_litellm, prompt, or_key, GEMINI_MODEL, 8000)
198
- f_deepseek = ex.submit(call_litellm, prompt, or_key, DEEPSEEK_MODEL, 12000)
224
+ f_gemini = ex.submit(call_litellm, prompt, or_key, GEMINI_MODEL, 16000, 150)
225
+ f_deepseek = ex.submit(call_litellm, build_deepseek_prompt(prompt), or_key, DEEPSEEK_MODEL, 24000, 350)
199
226
  f_qwen = ex.submit(call_litellm_stream, prompt, or_key, QWEN_MODEL, 8000)
200
227
  f_glm = ex.submit(call_litellm, prompt, or_key, GLM_MODEL, 8000)
201
228
 
@@ -51,12 +51,12 @@ def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys):
51
51
  fails while the rest succeed — partial failure, not total, not silent."""
52
52
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
53
53
 
54
- def fake_call_litellm(prompt, key, model, max_tokens=2000):
54
+ def fake_call_litellm(prompt, key, model, max_tokens=2000, timeout=90):
55
55
  if model == m.GLM_MODEL:
56
56
  return m.PanelResult.failure(model, "HTTP 503: upstream error")
57
57
  return m.PanelResult.success(model, f"analysis from {model}")
58
58
 
59
- def fake_call_stream(prompt, key, model, max_tokens=2000):
59
+ def fake_call_stream(prompt, key, model, max_tokens=2000, timeout=90):
60
60
  return m.PanelResult.success(model, f"analysis from {model}")
61
61
 
62
62
  monkeypatch.setattr(m, "call_litellm", fake_call_litellm)
@@ -73,7 +73,7 @@ def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys):
73
73
  def test_all_panels_succeed_exits_zero(monkeypatch, capsys):
74
74
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
75
75
 
76
- def fake_call(prompt, key, model, max_tokens=2000):
76
+ def fake_call(prompt, key, model, max_tokens=2000, timeout=90):
77
77
  return m.PanelResult.success(model, f"analysis from {model}")
78
78
 
79
79
  monkeypatch.setattr(m, "call_litellm", fake_call)
@@ -84,3 +84,33 @@ def test_all_panels_succeed_exits_zero(monkeypatch, capsys):
84
84
  captured = capsys.readouterr()
85
85
  assert "PANEL FAILED" not in captured.out
86
86
  assert captured.err == ""
87
+
88
+
89
+ def test_deepseek_and_gemini_get_raised_limits(monkeypatch, capsys):
90
+ """Regression guard for the 2026-08-25 timeout/truncation incident: DeepSeek
91
+ (reasoning model) and Gemini (long synthesis, was hitting its max_tokens cap)
92
+ must be fanned out with a higher max_tokens and timeout than the plain
93
+ 4000/90 defaults, or they will fail again under real load."""
94
+ monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
95
+ calls = {}
96
+
97
+ def fake_call(prompt, key, model, max_tokens=4000, timeout=90):
98
+ calls[model] = (max_tokens, timeout)
99
+ return m.PanelResult.success(model, f"analysis from {model}")
100
+
101
+ def fake_call_stream(prompt, key, model, max_tokens=4000, timeout=90):
102
+ calls[model] = (max_tokens, timeout)
103
+ return m.PanelResult.success(model, f"analysis from {model}")
104
+
105
+ monkeypatch.setattr(m, "call_litellm", fake_call)
106
+ monkeypatch.setattr(m, "call_litellm_stream", fake_call_stream)
107
+
108
+ code = _run_main(monkeypatch, ["council_fanout.py", "goal"])
109
+ assert code == 0
110
+
111
+ deepseek_max_tokens, deepseek_timeout = calls[m.DEEPSEEK_MODEL]
112
+ gemini_max_tokens, gemini_timeout = calls[m.GEMINI_MODEL]
113
+ assert deepseek_max_tokens > 12000
114
+ assert deepseek_timeout > 90
115
+ assert gemini_max_tokens > 8000
116
+ assert gemini_timeout >= 90
@@ -88,7 +88,24 @@ def build_prompt(goal, context):
88
88
  return PANEL_PROMPT_NO_CONTEXT.format(goal=goal)
89
89
 
90
90
 
91
- def call_litellm(prompt, key, model, max_tokens=6000):
91
+ # DeepSeek-only addendum: the shared "No length limit" instruction above causes
92
+ # DeepSeek specifically to reliably fill the entire max_tokens budget regardless
93
+ # of prompt scope (confirmed via real calls against idea-council's identical
94
+ # prompt trait on 2026-08-25), which reads as a truncation error in the call log
95
+ # every round. Gemini/Qwen/GLM don't show this behavior, so only DeepSeek's
96
+ # prompt gets this addendum — the other panels keep the unmodified instruction.
97
+ DEEPSEEK_BUDGET_ADDENDUM = """
98
+
99
+ Budget your answer to conclude cleanly within roughly 16,000-20,000 tokens. \
100
+ Prioritize depth on the highest-leverage points over exhaustive coverage of every \
101
+ possible angle — a focused, complete answer beats a broader one cut off mid-thought."""
102
+
103
+
104
+ def build_deepseek_prompt(prompt):
105
+ return prompt + DEEPSEEK_BUDGET_ADDENDUM
106
+
107
+
108
+ def call_litellm(prompt, key, model, max_tokens=6000, timeout=90):
92
109
  url = "http://127.0.0.1:4000/chat/completions"
93
110
  body = json.dumps({
94
111
  "model": model,
@@ -103,9 +120,10 @@ def call_litellm(prompt, key, model, max_tokens=6000):
103
120
  })
104
121
  start = time.monotonic()
105
122
  try:
106
- with urllib.request.urlopen(req, timeout=90) as r:
123
+ with urllib.request.urlopen(req, timeout=timeout) as r:
107
124
  chunks = []
108
125
  usage = None
126
+ truncated = False
109
127
  for line in r:
110
128
  line = line.decode("utf-8").strip()
111
129
  if not line or not line.startswith("data: "):
@@ -116,7 +134,10 @@ def call_litellm(prompt, key, model, max_tokens=6000):
116
134
  try:
117
135
  d = json.loads(payload)
118
136
  if "choices" in d and d["choices"]:
119
- delta = d["choices"][0].get("delta", {})
137
+ choice = d["choices"][0]
138
+ if choice.get("finish_reason") == "length":
139
+ truncated = True
140
+ delta = choice.get("delta", {})
120
141
  text_chunk = delta.get("content") or delta.get("reasoning_content") or delta.get("reasoning") or ""
121
142
  if text_chunk:
122
143
  chunks.append(text_chunk)
@@ -124,9 +145,12 @@ def call_litellm(prompt, key, model, max_tokens=6000):
124
145
  usage = d["usage"]
125
146
  except json.JSONDecodeError:
126
147
  continue
127
- text = "".join(chunks)
128
- _log_panel_call(model, time.monotonic() - start, usage)
129
- return PanelResult.success(model, text.strip(), time.monotonic() - start)
148
+ text = "".join(chunks).strip()
149
+ _log_panel_call(model, time.monotonic() - start, usage,
150
+ error="truncated: hit max_tokens" if truncated else None)
151
+ if truncated:
152
+ text += "\n\n[response truncated — hit max_tokens cap]"
153
+ return PanelResult.success(model, text, time.monotonic() - start)
130
154
  except urllib.error.HTTPError as e:
131
155
  detail = e.read().decode()[:300]
132
156
  error = f"HTTP {e.code}: {detail}"
@@ -152,7 +176,7 @@ def main():
152
176
  usage_msg="Usage: plan_council_fanout.py 'raw goal' ['context']")
153
177
 
154
178
  # Fail fast: if the proxy itself is unreachable, every panel below will fail
155
- # the same way after its own 90s timeout. Detect that in ~1 request.
179
+ # the same way after its own (90-350s) timeout. Detect that in ~1 request.
156
180
  down_reason = preflight_proxy(or_key, caller="plan-council")
157
181
  if down_reason:
158
182
  render_and_exit([
@@ -160,9 +184,16 @@ def main():
160
184
  for m in (GEMINI_MODEL, DEEPSEEK_MODEL, QWEN_MODEL, GLM_MODEL)
161
185
  ])
162
186
 
187
+ # Gemini and DeepSeek get raised max_tokens + timeout — mirrors the fix
188
+ # proven against idea-council on 2026-08-25 (same "No length limit" prompt
189
+ # trait, same models, same proxy): Gemini's synthesis runs 7-8k completion
190
+ # tokens (old 6000 cap was even tighter than idea-council's old 8000), and
191
+ # DeepSeek is a reasoning model whose answers regularly exceed the old 90s
192
+ # window and the old 8000-token cap. Qwen and GLM keep their defaults —
193
+ # no failures reported for them.
163
194
  with concurrent.futures.ThreadPoolExecutor(max_workers=4) as ex:
164
- f_gemini = ex.submit(call_litellm, prompt, or_key, GEMINI_MODEL, 6000)
165
- f_deepseek = ex.submit(call_litellm, prompt, or_key, DEEPSEEK_MODEL, 8000)
195
+ f_gemini = ex.submit(call_litellm, prompt, or_key, GEMINI_MODEL, 16000, 150)
196
+ f_deepseek = ex.submit(call_litellm, build_deepseek_prompt(prompt), or_key, DEEPSEEK_MODEL, 24000, 350)
166
197
  f_qwen = ex.submit(call_litellm, prompt, or_key, QWEN_MODEL, 6000)
167
198
  f_glm = ex.submit(call_litellm, prompt, or_key, GLM_MODEL, 6000)
168
199
 
@@ -49,7 +49,7 @@ def test_proxy_fully_down_exits_one_not_zero(monkeypatch, capsys):
49
49
  def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys):
50
50
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
51
51
 
52
- def fake_call_litellm(prompt, key, model, max_tokens=3000):
52
+ def fake_call_litellm(prompt, key, model, max_tokens=3000, timeout=90):
53
53
  if model == m.QWEN_MODEL:
54
54
  return m.PanelResult.failure(model, "HTTP 503: upstream error")
55
55
  return m.PanelResult.success(model, f"plan from {model}")
@@ -67,7 +67,7 @@ def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys):
67
67
  def test_all_panels_succeed_exits_zero(monkeypatch, capsys):
68
68
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
69
69
  monkeypatch.setattr(m, "call_litellm",
70
- lambda prompt, key, model, max_tokens=3000:
70
+ lambda prompt, key, model, max_tokens=3000, timeout=90:
71
71
  m.PanelResult.success(model, f"plan from {model}"))
72
72
 
73
73
  code = _run_main(monkeypatch, ["plan_council_fanout.py", "goal"])
@@ -75,3 +75,73 @@ def test_all_panels_succeed_exits_zero(monkeypatch, capsys):
75
75
  captured = capsys.readouterr()
76
76
  assert "PANEL FAILED" not in captured.out
77
77
  assert captured.err == ""
78
+
79
+
80
+ class _FakeStreamResponse:
81
+ """Minimal stand-in for the urlopen(...) context manager, iterable over
82
+ raw SSE bytes lines the way call_litellm()'s `for line in r:` expects."""
83
+ def __init__(self, lines):
84
+ self._lines = lines
85
+
86
+ def __enter__(self):
87
+ return self
88
+
89
+ def __exit__(self, *a):
90
+ return False
91
+
92
+ def __iter__(self):
93
+ return iter(self._lines)
94
+
95
+
96
+ def test_call_litellm_marks_truncation_on_finish_reason_length(monkeypatch):
97
+ """Regression guard: plan-council's call_litellm() previously never checked
98
+ finish_reason=="length" at all (unlike idea/review-council), so a
99
+ max_tokens truncation passed completely silently — no log entry, no marker
100
+ in the text, no way to distinguish it from a genuinely complete answer.
101
+ Mirrors idea-council's truncation-marker handling."""
102
+ lines = [
103
+ b'data: {"choices":[{"delta":{"content":"partial plan"},"finish_reason":null}]}\n',
104
+ b'data: {"choices":[{"delta":{},"finish_reason":"length"}],"usage":{"completion_tokens":6000}}\n',
105
+ b'data: [DONE]\n',
106
+ ]
107
+ monkeypatch.setattr(m.urllib.request, "urlopen",
108
+ lambda req, timeout=90: _FakeStreamResponse(lines))
109
+ logged = {}
110
+ monkeypatch.setattr(m, "_log_panel_call",
111
+ lambda model, duration, usage, error=None: logged.update(error=error))
112
+
113
+ result = m.call_litellm("prompt", "key", m.DEEPSEEK_MODEL)
114
+
115
+ assert result.ok
116
+ assert "partial plan" in result.text
117
+ assert "[response truncated" in result.text
118
+ assert logged["error"] == "truncated: hit max_tokens"
119
+
120
+
121
+ def test_deepseek_and_gemini_get_raised_limits(monkeypatch, capsys):
122
+ """Regression guard mirroring idea-council's 2026-08-25 fix: DeepSeek
123
+ (reasoning model) and Gemini (long synthesis) must be fanned out with a
124
+ higher max_tokens and timeout than the plain 6000/90 defaults, or they
125
+ will fail again under real load. DeepSeek must also receive the budget
126
+ addendum, since it shares the "No length limit" prompt trait that made it
127
+ reliably fill any max_tokens budget."""
128
+ monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
129
+ calls = {}
130
+
131
+ def fake_call(prompt, key, model, max_tokens=6000, timeout=90):
132
+ calls[model] = (prompt, max_tokens, timeout)
133
+ return m.PanelResult.success(model, f"plan from {model}")
134
+
135
+ monkeypatch.setattr(m, "call_litellm", fake_call)
136
+
137
+ code = _run_main(monkeypatch, ["plan_council_fanout.py", "goal"])
138
+ assert code == 0
139
+
140
+ deepseek_prompt, deepseek_max_tokens, deepseek_timeout = calls[m.DEEPSEEK_MODEL]
141
+ gemini_prompt, gemini_max_tokens, gemini_timeout = calls[m.GEMINI_MODEL]
142
+ assert deepseek_max_tokens > 8000
143
+ assert deepseek_timeout > 90
144
+ assert gemini_max_tokens > 6000
145
+ assert gemini_timeout >= 90
146
+ assert "Budget your answer" in deepseek_prompt
147
+ assert "Budget your answer" not in gemini_prompt
@@ -88,7 +88,24 @@ def build_prompt(goal, diff):
88
88
  return PANEL_PROMPT.format(goal=goal, diff=diff)
89
89
 
90
90
 
91
- def call_litellm(prompt, key, model, max_tokens=6000):
91
+ # DeepSeek-only addendum: the shared "No length limit" instruction above causes
92
+ # DeepSeek specifically to reliably fill the entire max_tokens budget regardless
93
+ # of prompt scope (confirmed via real calls against idea-council's identical
94
+ # prompt trait on 2026-08-25), which reads as a truncation error in the call log
95
+ # every round. Gemini/Qwen/GLM don't show this behavior, so only DeepSeek's
96
+ # prompt gets this addendum — the other panels keep the unmodified instruction.
97
+ DEEPSEEK_BUDGET_ADDENDUM = """
98
+
99
+ Budget your answer to conclude cleanly within roughly 16,000-20,000 tokens. \
100
+ Prioritize depth on the highest-leverage points over exhaustive coverage of every \
101
+ possible angle — a focused, complete answer beats a broader one cut off mid-thought."""
102
+
103
+
104
+ def build_deepseek_prompt(prompt):
105
+ return prompt + DEEPSEEK_BUDGET_ADDENDUM
106
+
107
+
108
+ def call_litellm(prompt, key, model, max_tokens=6000, timeout=120):
92
109
  url = "http://127.0.0.1:4000/chat/completions"
93
110
  body = json.dumps({
94
111
  "model": model,
@@ -102,7 +119,7 @@ def call_litellm(prompt, key, model, max_tokens=6000):
102
119
  })
103
120
  start = time.monotonic()
104
121
  try:
105
- with urllib.request.urlopen(req, timeout=120) as r:
122
+ with urllib.request.urlopen(req, timeout=timeout) as r:
106
123
  d = json.load(r)
107
124
  msg = d["choices"][0]["message"]
108
125
  text = msg.get("content") or msg.get("reasoning_content") or msg.get("reasoning") or ""
@@ -118,7 +135,7 @@ def call_litellm(prompt, key, model, max_tokens=6000):
118
135
  return PanelResult.failure(model, e, time.monotonic() - start)
119
136
 
120
137
 
121
- def call_litellm_stream(prompt, key, model, max_tokens=6000):
138
+ def call_litellm_stream(prompt, key, model, max_tokens=6000, timeout=90):
122
139
  """Streaming variant required by litellm_qwen (Together AI backend rejects
123
140
  non-streaming requests for this model). Only collects delta.content —
124
141
  reasoning_content (chain-of-thought) is intentionally discarded."""
@@ -138,7 +155,7 @@ def call_litellm_stream(prompt, key, model, max_tokens=6000):
138
155
  parts = []
139
156
  usage = None
140
157
  try:
141
- with urllib.request.urlopen(req, timeout=90) as r:
158
+ with urllib.request.urlopen(req, timeout=timeout) as r:
142
159
  for raw_line in r:
143
160
  line = raw_line.decode("utf-8", "ignore").strip()
144
161
  if not line or not line.startswith("data: "):
@@ -195,7 +212,7 @@ def main():
195
212
  usage_msg="Usage: review_council_fanout.py 'review goal' 'path/to/diff_file'")
196
213
 
197
214
  # Fail fast: if the proxy itself is unreachable, every panel below will fail
198
- # the same way after its own (90-120s) timeout. Detect that in ~1 request.
215
+ # the same way after its own (90-350s) timeout. Detect that in ~1 request.
199
216
  down_reason = preflight_proxy(litellm_key, caller="review-council")
200
217
  if down_reason:
201
218
  render_and_exit([
@@ -203,9 +220,16 @@ def main():
203
220
  for m in (GEMINI_MODEL, DEEPSEEK_MODEL, QWEN_MODEL, GLM_MODEL)
204
221
  ])
205
222
 
223
+ # Gemini and DeepSeek get raised max_tokens + timeout — mirrors the fix
224
+ # proven against idea-council on 2026-08-25 (same "No length limit" prompt
225
+ # trait, same models, same proxy): Gemini's synthesis runs 7-8k completion
226
+ # tokens (old 6000 cap was even tighter than idea-council's old 8000), and
227
+ # DeepSeek is a reasoning model whose answers regularly exceed the old
228
+ # 120s window and the old 8000-token cap. Qwen and GLM keep their
229
+ # defaults — no failures reported for them.
206
230
  with concurrent.futures.ThreadPoolExecutor(max_workers=4) as ex:
207
- f_gemini = ex.submit(call_litellm, prompt, litellm_key, GEMINI_MODEL, 6000)
208
- f_deepseek = ex.submit(call_litellm, prompt, litellm_key, DEEPSEEK_MODEL, 8000)
231
+ f_gemini = ex.submit(call_litellm, prompt, litellm_key, GEMINI_MODEL, 16000, 150)
232
+ f_deepseek = ex.submit(call_litellm, build_deepseek_prompt(prompt), litellm_key, DEEPSEEK_MODEL, 24000, 350)
209
233
  f_qwen = ex.submit(call_litellm_stream, prompt, litellm_key, QWEN_MODEL, 6000)
210
234
  f_glm = ex.submit(call_litellm, prompt, litellm_key, GLM_MODEL, 6000)
211
235
 
@@ -62,12 +62,12 @@ def test_proxy_fully_down_exits_one_not_zero(monkeypatch, capsys, tmp_path):
62
62
  def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys, tmp_path):
63
63
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
64
64
 
65
- def fake_call_litellm(prompt, key, model, max_tokens=3000):
65
+ def fake_call_litellm(prompt, key, model, max_tokens=3000, timeout=120):
66
66
  if model == m.DEEPSEEK_MODEL:
67
67
  return m.PanelResult.failure(model, "HTTP 500: internal error")
68
68
  return m.PanelResult.success(model, f"review from {model}")
69
69
 
70
- def fake_call_stream(prompt, key, model, max_tokens=2000):
70
+ def fake_call_stream(prompt, key, model, max_tokens=2000, timeout=90):
71
71
  return m.PanelResult.success(model, f"review from {model}")
72
72
 
73
73
  monkeypatch.setattr(m, "call_litellm", fake_call_litellm)
@@ -84,7 +84,7 @@ def test_one_panel_errors_others_succeed_exits_two(monkeypatch, capsys, tmp_path
84
84
  def test_all_panels_succeed_exits_zero(monkeypatch, capsys, tmp_path):
85
85
  monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
86
86
 
87
- def fake_call(prompt, key, model, max_tokens=3000):
87
+ def fake_call(prompt, key, model, max_tokens=3000, timeout=90):
88
88
  return m.PanelResult.success(model, f"review from {model}")
89
89
 
90
90
  monkeypatch.setattr(m, "call_litellm", fake_call)
@@ -95,3 +95,37 @@ def test_all_panels_succeed_exits_zero(monkeypatch, capsys, tmp_path):
95
95
  captured = capsys.readouterr()
96
96
  assert "PANEL FAILED" not in captured.out
97
97
  assert captured.err == ""
98
+
99
+
100
+ def test_deepseek_and_gemini_get_raised_limits(monkeypatch, capsys, tmp_path):
101
+ """Regression guard mirroring idea-council's 2026-08-25 fix: DeepSeek
102
+ (reasoning model) and Gemini (long synthesis) must be fanned out with a
103
+ higher max_tokens and timeout than the plain 6000/120 defaults, or they
104
+ will fail again under real load. DeepSeek must also receive the budget
105
+ addendum, since it shares the "No length limit" prompt trait that made it
106
+ reliably fill any max_tokens budget."""
107
+ monkeypatch.setattr(m, "preflight_proxy", lambda key, timeout=5, caller=None: None)
108
+ calls = {}
109
+
110
+ def fake_call(prompt, key, model, max_tokens=6000, timeout=120):
111
+ calls[model] = (prompt, max_tokens, timeout)
112
+ return m.PanelResult.success(model, f"review from {model}")
113
+
114
+ def fake_call_stream(prompt, key, model, max_tokens=6000, timeout=90):
115
+ calls[model] = (prompt, max_tokens, timeout)
116
+ return m.PanelResult.success(model, f"review from {model}")
117
+
118
+ monkeypatch.setattr(m, "call_litellm", fake_call)
119
+ monkeypatch.setattr(m, "call_litellm_stream", fake_call_stream)
120
+
121
+ code = _run_main(monkeypatch, ["review_council_fanout.py", "goal", _diff_file(tmp_path)])
122
+ assert code == 0
123
+
124
+ deepseek_prompt, deepseek_max_tokens, deepseek_timeout = calls[m.DEEPSEEK_MODEL]
125
+ gemini_prompt, gemini_max_tokens, gemini_timeout = calls[m.GEMINI_MODEL]
126
+ assert deepseek_max_tokens > 8000
127
+ assert deepseek_timeout > 120
128
+ assert gemini_max_tokens > 6000
129
+ assert gemini_timeout >= 120
130
+ assert "Budget your answer" in deepseek_prompt
131
+ assert "Budget your answer" not in gemini_prompt
@@ -382,7 +382,7 @@ def build_reference_description(concept_ref: str, scene_name: str, deviations_js
382
382
 
383
383
  def read_item(item_id: str, items_path: str) -> dict:
384
384
  result = subprocess.run(
385
- ["python", str(_AGENT_DIR / "scribe_item_read.py"), item_id, "--items", items_path],
385
+ [sys.executable, str(_AGENT_DIR / "scribe_item_read.py"), item_id, "--items", items_path],
386
386
  capture_output=True, text=True
387
387
  )
388
388
  if result.returncode != 0:
@@ -468,7 +468,7 @@ def build_rich_comment(meta: dict, dispatch: dict, item_json: dict,
468
468
 
469
469
  def write_item(item_id: str, sha: str, items_path: str,
470
470
  issue_iid: int | None = None, issue_url: str | None = None):
471
- args = ["python", str(_AGENT_DIR / "scribe_item_write.py"), item_id, "--sha", sha, "--items", items_path]
471
+ args = [sys.executable, str(_AGENT_DIR / "scribe_item_write.py"), item_id, "--sha", sha, "--items", items_path]
472
472
  if issue_iid is not None:
473
473
  args += ["--issue-iid", str(issue_iid)]
474
474
  if issue_url:
@@ -2,9 +2,15 @@
2
2
 
3
3
  When making technical decisions, do not give much weight to development cost. Instead, prefer quality, simplicity, robustness, scalability, and long term maintainability.
4
4
  When doing bug fixes, always start with reproducing the bug in an E2E setting as closely aligned with how an end user would experience it as possible. This makes sure you find the real problem so your fix will actually solve it.
5
- If user has custom agent and other models in their custom agents respect them and launch with what was instructed. This takes higher priority.
6
5
  Use git CLI for GitLab access, never glab — we use GitLab, not GitHub.
7
- Always state all pending, open, or blocked items upfront and in full at the top of a response — never trail a reply with "one more thing pending" or drip-feed open items across later turns.
6
+ Always state all pending, open, or blocked items upfront and in full at the top of a response — never trail a reply with "one more thing pending" or drip-feed open items across later turns; an item surfaced later (e.g. mid-grill) gets flagged the moment it's found, not held to the end.
7
+ Always track multi-step work with TaskCreate/TaskList/TaskUpdate (persistent across sessions), falling back to TodoWrite only if Task tools are unavailable — never printed markdown checklists.
8
+ When planning or modifying work, start a wayfinder map for anything too big for one session, and always mirror the TODO items in that work's PRD/issue ticket so it stays current.
9
+ Never `taskkill /F` or force-stop a shared daemon or another session's process — it can be serving other concurrent chats too (confirmed incident: killing the shared router mid-session broke every other active chat); restart it gracefully via its own scheduled task instead.
10
+ Grill the operator once per new goal to lock scope and shared understanding; once scope is locked, execute autonomously end-to-end without re-confirming each step — grilling gates scope, not execution.
11
+ A new finding or one-off issue surfaced mid-task gets its own PRD/issue tracked separately — do not solve it inline in the same session; nudge the operator to open a new ticket instead.
12
+ Default to plain, simple technical English (ASD-STE100 style) and concise bullets/tables/ASCII diagrams over prose paragraphs.
13
+ In any report to the user, state each result once — never repeat an item already covered earlier in the same response or session.
8
14
 
9
15
  ## Model Routing (HARD RULE)
10
16
 
@@ -12,21 +18,16 @@ The main-loop model (Fable/Opus) is a scarce planning resource; burn Sonnet, not
12
18
 
13
19
  | Work | Who does it |
14
20
  |---|---|
15
- | Grilling, requirements, decisions, ADR judgments | Fable/Opus, main loop |
16
- | Architecture, planning, scaffolding design, orchestration | Fable/Opus, main loop |
17
- | Adversarial review of subagent output | Fable/Opus, main loop |
18
- | Writing code / HTML / docs / mocks / configs / scripts | Sonnet subagent (`generic-purpose-subagent` / `execution-worker-subagent`, `model: "claude-sonnet-5[1m]"`) |
19
- | Running + fixing tests, bulk edits, research gathering | Sonnet subagent (`generic-purpose-subagent` / `execution-worker-subagent`, `model: "claude-sonnet-5[1m]"`) |
21
+ | Grilling, requirements, decisions, ADR judgments; architecture/planning/scaffolding/orchestration; adversarial review of subagent output | Fable/Opus, main loop |
22
+ | Writing code/HTML/docs/mocks/configs/scripts; running+fixing tests; bulk edits; research gathering | Sonnet subagent (`generic-purpose-subagent` / `execution-worker-subagent`, `model: "claude-sonnet-5[1m]"`) |
20
23
 
21
24
  Standalone non-Claude subagents (an agent whose entire multi-turn loop runs as a LiteLLM-routed model, e.g. old `litellm_glm`/`litellm_deepseek_flash` workers) are retired — see `docs/pure-claude-mode.md`. The only legitimate non-Claude LLM calls left are one-shot, Claude-wrapped: the idea/plan/review councils and the scribe's synthesis fallback shell out from Python to LiteLLM for a single completion, with Claude (main loop or the council subagent) driving the call and synthesizing the result — never a subagent whose own reasoning loop is a non-Claude model.
22
25
 
23
- - Dispatch threshold: if the deliverable is > ~30 lines of file content, or > 2 mechanical steps, it goes to a worker subagent (see the table above for which model). Main loop may still do: reads needed for decisions, dispatch, review, and small edits to decision docs.
24
- - On Agent/Task dispatch without a custom agent, always pass `model: "sonnet"` explicitly. The bare `model:` tool parameter is schema-restricted to `sonnet`/`opus`/`haiku`/`fable` for unregistered dispatch types (`Explore`, `general-purpose`, `claude`) — they have no agent-definition file for the harness to read a model from, so any non-Claude slug there fails tool-schema validation (confirmed in production 2026-07-05). To actually get GLM-5.2 (or another LiteLLM-routed model) running a generic-purpose-shaped dispatch, use a REGISTERED project-specific agent whose own frontmatter names that model (e.g. `generic-purpose-subagent`) — that path reads the model server-side from the agent file, not from this parameter.
25
- - Custom agents that specify their own model override this (rule above takes priority).
26
+ - Fan-out is the standing default, never a per-request instruction: anything not already in context (a new error, screenshot, log, file, ticket, git/AWS state) is looked up by a subagent that returns conclusions and saves them to one-brain; the main loop opens nothing itself except the one line a decision needs.
27
+ - Dispatch threshold: if the deliverable is > ~30 lines of file content, or > 2 mechanical steps (or any step whose raw output isn't needed verbatim for a decision), it goes to a worker subagent that returns conclusions only, never raw file dumps. Main loop holds only: reads needed for decisions, dispatch, review, and small edits to decision docs.
28
+ - On Agent/Task dispatch without a custom agent, always pass `model: "sonnet"` explicitly. The bare `model:` tool parameter is schema-restricted to `sonnet`/`opus`/`haiku`/`fable` for unregistered dispatch types (`Explore`, `general-purpose`, `claude`) — they have no agent-definition file for the harness to read a model from, so any non-Claude slug there fails tool-schema validation (confirmed in production 2026-07-05). To actually get GLM-5.2 (or another LiteLLM-routed model) running a generic-purpose-shaped dispatch, use a REGISTERED project-specific agent whose own frontmatter names that model (e.g. `generic-purpose-subagent`) — that path reads the model server-side from the agent file, not from this parameter. Custom agents that specify their own model override this table.
26
29
  - Loop shape: Fable plans → a worker subagent executes → Fable adversarially reviews → return to user or re-instruct subagents.
27
30
 
28
-
29
-
30
31
  ## Memory-First (every session)
31
32
 
32
33
  At the start of every session, before substantive work, call `mcp__claude_ai_one-brain__get_preferences` (scope=all) and `mcp__claude_ai_one-brain__recall` (query = the user's request) in parallel. Trust current code over recalled facts on conflict.
@@ -44,10 +45,7 @@ Prefer code over natural-language rules. Mechanical constraints (paths, formats,
44
45
  - Describe WHAT (goal, signals, exit codes, return shape); put HOW in scripts.
45
46
  - Triggers, classification tables, dispatch blocks, retry rules must be machine-parseable (YAML/JSON-shaped) so a validator can lint them.
46
47
  - If a behavior is critical for correctness (ordering, schema, retry caps, gate enforcement), write a hook/script that enforces it. Do not rely on the LLM reading prose and obeying — prose drifts, code doesn't.
47
-
48
- ## Autonomous Subagents
49
-
50
- When dispatching a subagent, pass WHAT (goal, task, context) — never HOW. The caller scopes the work; the subagent owns execution (tool choice, order, approach). HOW lives inside the subagent's own agent file, not in dispatch blocks.
48
+ - Same split applies to dispatch: pass WHAT (goal, task, context), never HOW. The caller scopes the work; the subagent owns execution (tool choice, order, approach) via its own agent file, not the dispatch prompt.
51
49
 
52
50
  ## Web Search Routing
53
51
 
@@ -62,6 +60,5 @@ When writing a memory file under `~/.claude/projects/*/memory/*.md`, also call `
62
60
  Whenever a session adds, edits, or removes an agent (`.agent.md`), a skill (`SKILL.md`), or a hook file, do all of the following without being asked:
63
61
 
64
62
  1. **GitLab issue.** Post an update to the relevant issue. Check for an existing on-topic thread first (e.g. a project's own "Agent Flow"-style issue) and append there; only open a new issue if the change is a genuinely distinct thread, not a continuation of ongoing work.
65
- 2. **One-brain memory.** Already covered by "Save without asking" above — reaffirmed here specifically for agent/skill/hook changes, since these are exactly the kind of architecture/convention facts that mandate covers.
66
- 3. **Docs.** Update any project docs (README roster tables, architecture docs) the change affects, so they don't silently go stale relative to the actual code.
67
- 4. **Global vs. local — check my-agents.** `C:/dev/my-agents` is the canonical SOURCE for hooks/agents deployed to `~/.claude/` (e.g. `my-agents/proxy/*.py` → `~/.claude/proxy/*.py`, `my-agents/agents/*.md` → `~/.claude/agents/*.md`) — confirmed by direct diff on 2026-07-05 that these can silently diverge (an entire session's worth of global hook fixes existed only in the deployed copy, never propagated to source, which would be lost on a future reinstall). If the change touched anything under `~/.claude/` (not a project-local `.claude/` directory), it is GLOBAL/shared — the same fix must also land in the matching my-agents source file, or flag explicitly why it doesn't apply there. This is a judgment call (is this change global-shared-infra vs. project-local?), not something a hook can auto-detect — always ask "did I just edit something under `~/.claude/`?" and if yes, check my-agents.
63
+ 2. **Docs.** Update any project docs (README roster tables, architecture docs) the change affects, so they don't silently go stale relative to the actual code.
64
+ 3. **Global vs. local — check my-agents.** `C:/dev/my-agents` is the canonical SOURCE for hooks/agents deployed to `~/.claude/` (e.g. `my-agents/proxy/*.py` → `~/.claude/proxy/*.py`, `my-agents/agents/*.md` → `~/.claude/agents/*.md`) — confirmed by direct diff on 2026-07-05 that these can silently diverge (an entire session's worth of global hook fixes existed only in the deployed copy, never propagated to source, which would be lost on a future reinstall). If the change touched anything under `~/.claude/` (not a project-local `.claude/` directory), it is GLOBAL/shared — the same fix must also land in the matching my-agents source file, or flag explicitly why it doesn't apply there. This is a judgment call (is this change global-shared-infra vs. project-local?), not something a hook can auto-detect — always ask "did I just edit something under `~/.claude/`?" and if yes, check my-agents.