forked from Rockachopa/Timmy-time-dashboard
fix: remove invalid show_tool_calls kwarg crashing Agent init (#157)
* fix: remove invalid show_tool_calls kwarg crashing Agent init (regression) show_tool_calls was removed inf95c960(Feb 26) because agno 2.5.x doesn't accept it, then reintroduced infd0ede0(Mar 8) without runtime testing — mocked tests hid the breakage. Replace the bogus assertion with a regression guard and an allowlist test that catches unknown kwargs before they reach production. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: auto-install git hooks, add black/isort to dev deps - Add .githooks/ with portable pre-commit hook (macOS + Linux) - make install now auto-activates hooks via core.hooksPath - Add black and isort to poetry dev group (were only in CI via raw pip) - Fix black formatting on 2 files flagged by CI - Fix test_autoresearch_perplexity patching wrong module path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Trip T <trip@local> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
21e2ae427a
commit
574031a55c
@@ -268,8 +268,11 @@ def test_create_timmy_includes_tools_for_large_model():
|
||||
assert kwargs["tools"] == [mock_toolkit]
|
||||
|
||||
|
||||
def test_create_timmy_show_tool_calls_matches_tool_capability():
|
||||
"""show_tool_calls should be True when tools are enabled, False otherwise."""
|
||||
def test_create_timmy_no_unsupported_agent_kwargs():
|
||||
"""Regression guard: show_tool_calls and tool_call_limit are not valid agno 2.x params.
|
||||
|
||||
These were removed in f95c960 (Feb 26) and must not be reintroduced.
|
||||
"""
|
||||
with patch("timmy.agent.Agent") as MockAgent, patch("timmy.agent.Ollama"), patch(
|
||||
"timmy.agent.SqliteDb"
|
||||
):
|
||||
@@ -278,5 +281,39 @@ def test_create_timmy_show_tool_calls_matches_tool_capability():
|
||||
create_timmy()
|
||||
|
||||
kwargs = MockAgent.call_args.kwargs
|
||||
# show_tool_calls is set based on whether tools are enabled
|
||||
assert "show_tool_calls" in kwargs
|
||||
assert "show_tool_calls" not in kwargs, "show_tool_calls is not a valid Agent param"
|
||||
|
||||
|
||||
def test_create_timmy_no_extra_kwargs():
|
||||
"""All kwargs passed to Agent() must be from the known-valid set.
|
||||
|
||||
agno is mocked globally in conftest, so we can't inspect the real class here.
|
||||
Instead, maintain an explicit allowlist of params validated against agno 2.5.5.
|
||||
If a new param is needed, verify it exists in agno first, then add it here.
|
||||
"""
|
||||
VALID_AGENT_KWARGS = {
|
||||
"name",
|
||||
"model",
|
||||
"db",
|
||||
"description",
|
||||
"add_history_to_context",
|
||||
"num_history_runs",
|
||||
"markdown",
|
||||
"tools",
|
||||
"tool_call_limit",
|
||||
"telemetry",
|
||||
}
|
||||
|
||||
with patch("timmy.agent.Agent") as MockAgent, patch("timmy.agent.Ollama"), patch(
|
||||
"timmy.agent.SqliteDb"
|
||||
):
|
||||
from timmy.agent import create_timmy
|
||||
|
||||
create_timmy()
|
||||
|
||||
kwargs = MockAgent.call_args.kwargs
|
||||
invalid = set(kwargs.keys()) - VALID_AGENT_KWARGS
|
||||
assert not invalid, (
|
||||
f"Unknown Agent kwargs {invalid} — verify they exist in agno "
|
||||
f"before adding to VALID_AGENT_KWARGS"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user