Stage 280: PR #1535 — pass agent.reasoning_effort into WebUI agents (salvages #1531)

This commit is contained in:
Hermes Bot
2026-05-03 16:51:34 +00:00
2 changed files with 34 additions and 1 deletions
+2 -1
View File
@@ -1817,7 +1817,7 @@ def _run_agent_streaming(
# the key is absent or invalid, pass None → agent uses its default.
try:
from api.config import parse_reasoning_effort as _parse_reff
_effort_cfg = _cfg.cfg.get('agent', {}) if isinstance(_cfg.cfg, dict) else {}
_effort_cfg = _cfg.get('agent', {}) if isinstance(_cfg, dict) else {}
_effort_raw = _effort_cfg.get('reasoning_effort') if isinstance(_effort_cfg, dict) else None
_reasoning_config = _parse_reff(_effort_raw)
except Exception:
@@ -1885,6 +1885,7 @@ def _run_agent_streaming(
_max_tokens_cfg or '',
_fallback_resolved or {},
sorted(_toolsets) if _toolsets else [],
_reasoning_config or {},
], sort_keys=True)
_agent_sig = _hashlib.sha256(_sig_blob.encode()).hexdigest()[:16]
+32
View File
@@ -608,6 +608,38 @@ def test_streaming_bridge_accepts_current_tool_progress_callback_signature(clean
"streaming.py must emit live tool completion SSE events"
def test_streaming_reads_reasoning_effort_from_config_dict(cleanup_test_sessions):
"""R17b: WebUI must read agent.reasoning_effort from the dict returned by get_config().
`get_config()` returns a plain dict (not a wrapper exposing `.cfg`). The
pre-fix line `_cfg.cfg.get('agent', {})` raised AttributeError that the
surrounding try/except swallowed, so `_reasoning_config` was always None
regardless of what `/reasoning <level>` had been set to. This static
source assertion pins the fix because the runtime symptom is silent.
"""
src = (REPO_ROOT / "api/streaming.py").read_text()
assert "_cfg.cfg" not in src, \
"get_config() returns a dict; accessing _cfg.cfg drops reasoning_config to None"
assert "_cfg.get('agent', {})" in src or '_cfg.get("agent", {})' in src, \
"streaming.py must read agent.reasoning_effort via the config dict"
def test_streaming_agent_cache_signature_includes_reasoning_config(cleanup_test_sessions):
"""R17c: changing reasoning effort mid-session must rebuild the cached per-session agent.
Without `_reasoning_config` participating in `_sig_blob`, the cache key
matches the old entry and the operator's `/reasoning xhigh` change has
no effect on the live session.
"""
src = (REPO_ROOT / "api/streaming.py").read_text()
start = src.find("_sig_blob = _json.dumps")
end = src.find("_agent_sig", start)
assert start >= 0 and end > start, "agent cache signature block not found"
sig_block = src[start:end]
assert "_reasoning_config" in sig_block, \
"agent cache signature must include reasoning_config so xhigh/medium changes take effect"
def test_messages_js_supports_live_reasoning_and_tool_completion(cleanup_test_sessions):
"""R18: messages.js must render live reasoning and react to tool completion events.
Without these handlers, the operator only sees generic Thinking… or nothing