e455e4afd0
tool_search now takes queries: string[] (searched independently against the same catalog, limit applies per query, default 5 / max 25) and returns the split shape: per-query groups carry tool names only, one shared tools map holds each matched tool's source, description (400-char cap) and required parameter names once. When some queries miss, a single top-level available_sources + hint block replaces the old per-response fallback. tool_describe now takes names: string[] and returns a map keyed by name; unknown names collect in not_found (with the refresh hint) and non-deferrable names keep their per-name spelling-check error in errors, so one bad name no longer fails the whole call. Duplicates dedupe silently. The shared tokenizer now applies Snowball stemming (english, exact-pinned snowballstemmer) at both index and query time, closing the measured plural/singular miss where 'issues' failed to return create_issue. The inline BM25 is unchanged. Stemmer instances are thread-local (they carry mutable parse state and bridge dispatch can run on parallel tool-call threads). New config knobs under tools.tool_search: max_queries / max_describe_names (default 10 each, floor 1, no upper clamp) bound the per-call array inputs; over-cap calls error so the model repairs in one round-trip. No backward compatibility with the single query/name shapes, by decision. scripts/analyze_livetest.py renders both shapes since transcripts on disk may predate this change.
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
"""Regression tests for A2A client-tool schema registration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from plugins.platforms.a2a import tools as a2a_tools
|
|
from tools import tool_search
|
|
from tools.registry import ToolRegistry
|
|
|
|
|
|
def test_a2a_call_schema_round_trips_through_tool_describe(monkeypatch):
|
|
registry = ToolRegistry()
|
|
|
|
class _Context:
|
|
def register_tool(self, name, toolset, schema, handler, **kwargs):
|
|
registry.register(
|
|
name=name,
|
|
toolset=toolset,
|
|
schema=schema,
|
|
handler=handler,
|
|
**kwargs,
|
|
)
|
|
|
|
a2a_tools.register_tools(_Context())
|
|
definitions = registry.get_definitions({"a2a_call"})
|
|
monkeypatch.setattr(
|
|
tool_search,
|
|
"is_deferrable_tool_name",
|
|
lambda name: name == "a2a_call",
|
|
)
|
|
|
|
described = json.loads(
|
|
tool_search.dispatch_tool_describe(
|
|
{"names": ["a2a_call"]},
|
|
current_tool_defs=definitions,
|
|
)
|
|
)["tools"]["a2a_call"]
|
|
|
|
assert described["description"]
|
|
assert described["parameters"]["required"] == ["agent", "message"]
|
|
assert set(described["parameters"]["properties"]) == {
|
|
"agent",
|
|
"message",
|
|
"context_id",
|
|
}
|