INNER CODE UNIT · Python
call_tool
skyportal/skyportal · services/assistant/app.py:142
def call_tool(token, name, arguments, offered, context_id=None):
"""Run one tool, refusing any that was not offered.
The token carries the user's own permissions, so this is what stops a model
talked into it by the text of a circular from writing anything.
"""
if name not in offered:
raise PermissionError(f"{name} was not offered for this question")
if name in FILTER_WRITE_TOOLS and not targets_page_filter(arguments, context_id):
raise PermissionError(f"{name} may only change the filter on this page")
result = _rpc(
token,
"tools/call",
{"name": name, "arguments": arguments},
120,
tool_name=name,
)
return "\n".join(