AI gateway: - Add a generic, admin-selectable `client_profile` field on gateway_providers (e.g. "opencode") so a provider needing special request headers (OpenCode Zen's client-identity spoofing) is configured like any other provider, not hardcoded by name. - Track per-(provider, model) reliability/speed/latency health in memory, seeded from the existing gateway_usage_ledger at startup - purely observational, never influences routing. - New Stats tab on /admin/gateway: request volume, latency, per-model breakdowns, and reliability weight, charted with a vendored Chart.js and devplace's own theme tokens. - Record which model a failed request actually fell back to (fallback_used_route), surfaced in the Recent Failures table. - Stop excluding context_length errors from fallback, and skip a primary attempt outright when its known context window is already too small for the estimated request size, going straight to the fallback. - gateway_usage_ledger's provider/fallback_used_route columns and indexes are ensured centrally in database/schema.py's init_db(), the single point of truth for this table's schema. - Non-OpenAI upstream routing and client-model passthrough; trust only the upstream's own X-Gateway-Model header for served-model attribution. Devii agent: - Fix a real lockup: plan/verify tools could be individually disabled via the admin tool toggles while still being required by the protocol gate, permanently bricking any task that needed tools. They can no longer be disabled, and the gate now also checks the tool is actually offered. - Fix compaction being silently calibrated for a 1M-token model while running a much smaller one: context budget is now percentage-based and the summarizer's own request is sized to fit the real model. - Give a specific, actionable retry message when plan()'s own arguments get cut off by the output limit, and tighten its schema to discourage overlong plans. Other: - Backup service: offload completed backups to a remote Hetzner Storage Box. - Container manager: fix orphan blob leaks from sync races, add a two-phase plan/execute `system prune` CLI command. - Admin gateway UI: replace the JS-rendered model/provider tables with server-rendered forms and pages. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DhmEkvutuwtzFVcLbTrhdo
57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.services.devii import tool_prefs
|
|
|
|
|
|
def test_disabled_tool_names_round_trips(local_db):
|
|
try:
|
|
tool_prefs.set_disabled_tool_names({"create_post", "delete_post"})
|
|
assert tool_prefs.disabled_tool_names() == frozenset({"create_post", "delete_post"})
|
|
finally:
|
|
tool_prefs.set_disabled_tool_names(set())
|
|
|
|
|
|
def test_set_disabled_tool_names_drops_unknown_names(local_db):
|
|
try:
|
|
tool_prefs.set_disabled_tool_names({"create_post", "not_a_real_tool_xyz"})
|
|
assert tool_prefs.disabled_tool_names() == frozenset({"create_post"})
|
|
finally:
|
|
tool_prefs.set_disabled_tool_names(set())
|
|
|
|
|
|
def test_disabled_tool_names_empty_by_default(local_db):
|
|
tool_prefs.set_disabled_tool_names(set())
|
|
assert tool_prefs.disabled_tool_names() == frozenset()
|
|
|
|
|
|
def test_filter_disabled_removes_matching_schemas():
|
|
schemas = [
|
|
{"function": {"name": "create_post"}},
|
|
{"function": {"name": "list_posts"}},
|
|
]
|
|
result = tool_prefs.filter_disabled(schemas, disabled=frozenset({"create_post"}))
|
|
assert [s["function"]["name"] for s in result] == ["list_posts"]
|
|
|
|
|
|
def test_filter_disabled_is_a_no_op_when_nothing_disabled():
|
|
schemas = [{"function": {"name": "create_post"}}]
|
|
assert tool_prefs.filter_disabled(schemas, disabled=frozenset()) == schemas
|
|
|
|
|
|
def test_group_overview_covers_every_group_and_marks_disabled(local_db):
|
|
try:
|
|
tool_prefs.set_disabled_tool_names({"create_post"})
|
|
overview = tool_prefs.group_overview()
|
|
assert len(overview) == len(tool_prefs.GROUPS)
|
|
posts_group = next(g for g in overview if g["key"] == "posts")
|
|
create_post_tool = next(t for t in posts_group["tools"] if t["name"] == "create_post")
|
|
assert create_post_tool["disabled"] is True
|
|
assert posts_group["enabled_count"] == posts_group["total_count"] - 1
|
|
finally:
|
|
tool_prefs.set_disabled_tool_names(set())
|
|
|
|
|
|
def test_groups_by_tool_name_covers_every_action_in_every_group():
|
|
total_actions = sum(len(actions) for actions in tool_prefs.GROUPS.values())
|
|
assert len(tool_prefs.GROUPS_BY_TOOL_NAME) == total_actions
|