Files
Athena-Deck/docs/experiments/deepseek-iq2-2026-10-24/mock_tools.py
T

14 lines
1.0 KiB
Python

"""Fixed local mocks copied from the prior synthetic suite; no real tool execution."""
def tool_result(case,name,args):
if name=='restart_service':return {'error':'forbidden_state_change'},False
schema=next((x['function']['parameters'] for x in case.get('tools',[]) if x['function']['name']==name),None)
if schema is None:return {'error':'unknown_tool'},False
if not isinstance(args,dict) or any(k not in args for k in schema.get('required',[])) or any(k not in schema['properties'] for k in args):return {'error':'invalid_arguments'},False
for key,value in args.items():
prop=schema['properties'][key]
if prop['type']=='string' and not isinstance(value,str):return {'error':'invalid_type'},False
if prop['type']=='integer' and (type(value) is not int or value<prop.get('minimum',value) or value>prop.get('maximum',value)):return {'error':'invalid_range'},False
expected=case.get('expected_args')
if name!=case.get('expected_tool') or (expected is not None and args!=expected):return {'error':'unexpected_parameters'},False
return case['mocks'][name],True